38 |
|
|
39 |
package javax.swing.plaf.metal; |
package javax.swing.plaf.metal; |
40 |
|
|
41 |
|
import java.awt.event.ContainerListener; |
42 |
|
import java.beans.PropertyChangeListener; |
43 |
|
|
44 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
45 |
|
import javax.swing.JToolBar; |
46 |
|
import javax.swing.border.Border; |
47 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
48 |
import javax.swing.plaf.basic.BasicToolBarUI; |
import javax.swing.plaf.basic.BasicToolBarUI; |
49 |
|
|
50 |
|
/** |
51 |
|
* A UI delegate for the {@link JToolBar} component. |
52 |
|
*/ |
53 |
public class MetalToolBarUI |
public class MetalToolBarUI |
54 |
extends BasicToolBarUI |
extends BasicToolBarUI |
55 |
{ |
{ |
56 |
|
|
57 |
|
/** |
58 |
|
* A listener that responds when components are added to or removed from the |
59 |
|
* toolbar. This class is no longer used - the required behaviour is now |
60 |
|
* handled in the super class. |
61 |
|
* |
62 |
|
* @see MetalToolBarUI#createContainerListener() |
63 |
|
*/ |
64 |
|
protected class MetalContainerListener |
65 |
|
extends BasicToolBarUI.ToolBarContListener |
66 |
|
{ |
67 |
|
/** |
68 |
|
* Creates a new instance. |
69 |
|
*/ |
70 |
|
protected MetalContainerListener() |
71 |
|
{ |
72 |
|
} |
73 |
|
} |
74 |
|
|
75 |
// FIXME: maybe replace by a Map of instances when this becomes stateful |
/** |
76 |
/** The shared UI instance for MetalToolBarUIs */ |
* A listener that responds to property change events. This class is no |
77 |
private static MetalToolBarUI instance = null; |
* longer used - the required behaviour is now handled in the super class. |
78 |
|
* |
79 |
|
* @see MetalToolBarUI#createRolloverListener() |
80 |
|
*/ |
81 |
|
protected class MetalRolloverListener |
82 |
|
extends BasicToolBarUI.PropertyListener |
83 |
|
{ |
84 |
|
/** |
85 |
|
* Creates a new instance. |
86 |
|
*/ |
87 |
|
protected MetalRolloverListener() |
88 |
|
{ |
89 |
|
} |
90 |
|
} |
91 |
|
|
92 |
|
/** |
93 |
|
* The container listener (an implementation specific field, according to the |
94 |
|
* spec, and not used in GNU Classpath). |
95 |
|
*/ |
96 |
|
protected ContainerListener contListener; |
97 |
|
|
98 |
|
/** |
99 |
|
* The rollover listener (an implementation specific field, according to the |
100 |
|
* spec, and not used in GNU Classpath). |
101 |
|
*/ |
102 |
|
protected PropertyChangeListener rolloverListener; |
103 |
|
|
104 |
/** |
/** |
105 |
* Constructs a new instance of MetalToolBarUI. |
* Creates a new instance of this UI delegate. |
106 |
*/ |
*/ |
107 |
public MetalToolBarUI() |
public MetalToolBarUI() |
108 |
{ |
{ |
110 |
} |
} |
111 |
|
|
112 |
/** |
/** |
113 |
* Returns an instance of MetalToolBarUI. |
* Returns a new instance of <code>MetalToolBarUI</code>. |
114 |
* |
* |
115 |
* @param component the component for which we return an UI instance |
* @param component the component for which we return an UI instance |
116 |
* |
* |
117 |
* @return an instance of MetalToolBarUI |
* @return A new instance of <code>MetalToolBarUI</code>. |
118 |
*/ |
*/ |
119 |
public static ComponentUI createUI(JComponent component) |
public static ComponentUI createUI(JComponent component) |
120 |
{ |
{ |
121 |
if (instance == null) |
return new MetalToolBarUI(); |
122 |
instance = new MetalToolBarUI(); |
} |
123 |
return instance; |
|
124 |
|
/** |
125 |
|
* Returns <code>null</code> as permitted by recent versions of the API |
126 |
|
* specification. Originally it seems this method returned a new instance of |
127 |
|
* {@link MetalRolloverListener}, but this is now redundant. |
128 |
|
* |
129 |
|
* @return <code>null</code>. |
130 |
|
*/ |
131 |
|
protected PropertyChangeListener createRolloverListener() |
132 |
|
{ |
133 |
|
return null; |
134 |
|
} |
135 |
|
|
136 |
|
/** |
137 |
|
* Returns <code>null</code> as permitted by recent versions of the API |
138 |
|
* specification. Originally it seems this method returned a new instance of |
139 |
|
* {@link MetalContainerListener}, but this is now redundant. |
140 |
|
* |
141 |
|
* @return <code>null</code>. |
142 |
|
*/ |
143 |
|
protected ContainerListener createContainerListener() |
144 |
|
{ |
145 |
|
return null; |
146 |
|
} |
147 |
|
|
148 |
|
/** |
149 |
|
* Returns a border with no rollover effect for buttons in the tool bar. |
150 |
|
* |
151 |
|
* @return A border. |
152 |
|
* |
153 |
|
* @see MetalBorders#getToolbarButtonBorder() |
154 |
|
*/ |
155 |
|
protected Border createNonRolloverBorder() |
156 |
|
{ |
157 |
|
return MetalBorders.getToolbarButtonBorder(); |
158 |
} |
} |
159 |
|
|
160 |
} |
} |