author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 23632 | jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonMenuItemUI.java@cd7a34d12e8c |
child 39542 | 1073ea3df2c7 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.java.swing.plaf.motif; |
|
27 |
||
28 |
import javax.swing.*; |
|
29 |
import javax.swing.event.*; |
|
30 |
import javax.swing.plaf.*; |
|
31 |
import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI; |
|
32 |
||
33 |
import java.awt.*; |
|
34 |
import java.awt.event.*; |
|
35 |
import java.io.Serializable; |
|
36 |
||
37 |
||
38 |
/** |
|
39 |
* MotifRadioButtonMenuItem implementation |
|
40 |
* <p> |
|
41 |
* <strong>Warning:</strong> |
|
42 |
* Serialized objects of this class will not be compatible with |
|
43 |
* future Swing releases. The current serialization support is appropriate |
|
44 |
* for short term storage or RMI between applications running the same |
|
45 |
* version of Swing. A future release of Swing will provide support for |
|
46 |
* long term persistence. |
|
47 |
* |
|
48 |
* @author Georges Saab |
|
49 |
* @author Rich Schiavi |
|
50 |
*/ |
|
51 |
public class MotifRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI |
|
52 |
{ |
|
53 |
protected ChangeListener changeListener; |
|
54 |
||
55 |
public static ComponentUI createUI(JComponent b) { |
|
56 |
return new MotifRadioButtonMenuItemUI(); |
|
57 |
} |
|
58 |
||
59 |
protected void installListeners() { |
|
60 |
super.installListeners(); |
|
61 |
changeListener = createChangeListener(menuItem); |
|
62 |
menuItem.addChangeListener(changeListener); |
|
63 |
} |
|
64 |
||
65 |
protected void uninstallListeners() { |
|
66 |
super.uninstallListeners(); |
|
67 |
menuItem.removeChangeListener(changeListener); |
|
68 |
} |
|
69 |
||
70 |
protected ChangeListener createChangeListener(JComponent c) { |
|
71 |
return new ChangeHandler(); |
|
72 |
} |
|
73 |
||
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
74 |
@SuppressWarnings("serial") // Same-version serialization only |
2 | 75 |
protected class ChangeHandler implements ChangeListener, Serializable { |
76 |
public void stateChanged(ChangeEvent e) { |
|
77 |
JMenuItem c = (JMenuItem)e.getSource(); |
|
78 |
LookAndFeel.installProperty(c, "borderPainted", c.isArmed()); |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
protected MouseInputListener createMouseInputListener(JComponent c) { |
|
83 |
return new MouseInputHandler(); |
|
84 |
} |
|
85 |
||
86 |
||
87 |
protected class MouseInputHandler implements MouseInputListener { |
|
88 |
public void mouseClicked(MouseEvent e) {} |
|
89 |
public void mousePressed(MouseEvent e) { |
|
90 |
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); |
|
91 |
manager.setSelectedPath(getPath()); |
|
92 |
} |
|
93 |
public void mouseReleased(MouseEvent e) { |
|
94 |
MenuSelectionManager manager = |
|
95 |
MenuSelectionManager.defaultManager(); |
|
96 |
JMenuItem menuItem = (JMenuItem)e.getComponent(); |
|
97 |
Point p = e.getPoint(); |
|
98 |
if(p.x >= 0 && p.x < menuItem.getWidth() && |
|
99 |
p.y >= 0 && p.y < menuItem.getHeight()) { |
|
100 |
manager.clearSelectedPath(); |
|
101 |
menuItem.doClick(0); |
|
102 |
} else { |
|
103 |
manager.processMouseEvent(e); |
|
104 |
} |
|
105 |
} |
|
106 |
public void mouseEntered(MouseEvent e) {} |
|
107 |
public void mouseExited(MouseEvent e) {} |
|
108 |
public void mouseDragged(MouseEvent e) { |
|
109 |
MenuSelectionManager.defaultManager().processMouseEvent(e); |
|
110 |
} |
|
111 |
public void mouseMoved(MouseEvent e) { } |
|
112 |
} |
|
113 |
||
114 |
} |