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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25
26 package javax.swing;
27
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.ComponentOrientation;
31 import java.awt.Container;
32 import java.awt.Dimension;
33 import java.awt.Graphics;
34 import java.awt.Insets;
35 import java.awt.LayoutManager;
36 import java.awt.LayoutManager2;
37 import java.awt.event.*;
38 import java.beans.*;
39
40 import javax.swing.border.Border;
41 import javax.swing.plaf.*;
42 import javax.accessibility.*;
43
44 import java.io.Serializable;
45 import java.io.ObjectOutputStream;
46 import java.io.ObjectInputStream;
47 import java.io.IOException;
48 import java.util.Hashtable;
49
50
51 /**
52 * <code>JToolBar</code> provides a component that is useful for
53 * displaying commonly used <code>Action</code>s or controls.
54 * For examples and information on using tool bars see
55 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/toolbar.html">How to Use Tool Bars</a>,
56 * a section in <em>The Java Tutorial</em>.
57 *
58 * <p>
59 * With most look and feels,
60 * the user can drag out a tool bar into a separate window
61 * (unless the <code>floatable</code> property is set to <code>false</code>).
62 * For drag-out to work correctly, it is recommended that you add
63 * <code>JToolBar</code> instances to one of the four "sides" of a
64 * container whose layout manager is a <code>BorderLayout</code>,
65 * and do not add children to any of the other four "sides".
66 * <p>
67 * <strong>Warning:</strong> Swing is not thread safe. For more
68 * information see <a
69 * href="package-summary.html#threading">Swing's Threading
70 * Policy</a>.
71 * <p>
72 * <strong>Warning:</strong>
73 * Serialized objects of this class will not be compatible with
74 * future Swing releases. The current serialization support is
75 * appropriate for short term storage or RMI between applications running
76 * the same version of Swing. As of 1.4, support for long term storage
77 * of all JavaBeans™
78 * has been added to the <code>java.beans</code> package.
79 * Please see {@link java.beans.XMLEncoder}.
80 *
81 * @beaninfo
82 * attribute: isContainer true
83 * description: A component which displays commonly used controls or Actions.
84 *
85 * @author Georges Saab
86 * @author Jeff Shapiro
87 * @see Action
88 * @since 1.2
89 */
90 @SuppressWarnings("serial") // Same-version serialization only
91 public class JToolBar extends JComponent implements SwingConstants, Accessible
92 {
93 /**
94 * @see #getUIClassID
95 * @see #readObject
96 */
97 private static final String uiClassID = "ToolBarUI";
98
99 private boolean paintBorder = true;
100 private Insets margin = null;
101 private boolean floatable = true;
102 private int orientation = HORIZONTAL;
103
104 /**
105 * Creates a new tool bar; orientation defaults to <code>HORIZONTAL</code>.
106 */
107 public JToolBar()
108 {
109 this( HORIZONTAL );
158 addPropertyChangeListener( layout );
159
160 updateUI();
161 }
162
163 /**
164 * Returns the tool bar's current UI.
165 *
166 * @return the tool bar's current UI.
167 * @see #setUI
168 */
169 public ToolBarUI getUI() {
170 return (ToolBarUI)ui;
171 }
172
173 /**
174 * Sets the L&F object that renders this component.
175 *
176 * @param ui the <code>ToolBarUI</code> L&F object
177 * @see UIDefaults#getUI
178 * @beaninfo
179 * bound: true
180 * hidden: true
181 * attribute: visualUpdate true
182 * description: The UI object that implements the Component's LookAndFeel.
183 */
184 public void setUI(ToolBarUI ui) {
185 super.setUI(ui);
186 }
187
188 /**
189 * Notification from the <code>UIFactory</code> that the L&F has changed.
190 * Called to replace the UI with the latest version from the
191 * <code>UIFactory</code>.
192 *
193 * @see JComponent#updateUI
194 */
195 public void updateUI() {
196 setUI((ToolBarUI)UIManager.getUI(this));
197 // GTKLookAndFeel installs a different LayoutManager, and sets it
198 // to null after changing the look and feel, so, install the default
199 // if the LayoutManager is null.
200 if (getLayout() == null) {
201 setLayout(new DefaultToolBarLayout(getOrientation()));
202 }
203 invalidate();
204 }
205
206
207
208 /**
209 * Returns the name of the L&F class that renders this component.
210 *
211 * @return the string "ToolBarUI"
212 * @see JComponent#getUIClassID
213 * @see UIDefaults#getUI
214 */
215 public String getUIClassID() {
216 return uiClassID;
217 }
218
219
220 /**
221 * Returns the index of the specified component.
222 * (Note: Separators occupy index positions.)
223 *
224 * @param c the <code>Component</code> to find
225 * @return an integer indicating the component's position,
226 * where 0 is first
227 */
228 public int getComponentIndex(Component c) {
229 int ncomponents = this.getComponentCount();
230 Component[] component = this.getComponents();
231 for (int i = 0 ; i < ncomponents ; i++) {
232 Component comp = component[i];
233 if (comp == c)
234 return i;
249 if ( i >= 0 && i < ncomponents) {
250 Component[] component = this.getComponents();
251 return component[i];
252 }
253 return null;
254 }
255
256 /**
257 * Sets the margin between the tool bar's border and
258 * its buttons. Setting to <code>null</code> causes the tool bar to
259 * use the default margins. The tool bar's default <code>Border</code>
260 * object uses this value to create the proper margin.
261 * However, if a non-default border is set on the tool bar,
262 * it is that <code>Border</code> object's responsibility to create the
263 * appropriate margin space (otherwise this property will
264 * effectively be ignored).
265 *
266 * @param m an <code>Insets</code> object that defines the space
267 * between the border and the buttons
268 * @see Insets
269 * @beaninfo
270 * description: The margin between the tool bar's border and contents
271 * bound: true
272 * expert: true
273 */
274 public void setMargin(Insets m)
275 {
276 Insets old = margin;
277 margin = m;
278 firePropertyChange("margin", old, m);
279 revalidate();
280 repaint();
281 }
282
283 /**
284 * Returns the margin between the tool bar's border and
285 * its buttons.
286 *
287 * @return an <code>Insets</code> object containing the margin values
288 * @see Insets
289 */
290 public Insets getMargin()
291 {
292 if(margin == null) {
293 return new Insets(0,0,0,0);
300 * Gets the <code>borderPainted</code> property.
301 *
302 * @return the value of the <code>borderPainted</code> property
303 * @see #setBorderPainted
304 */
305 public boolean isBorderPainted()
306 {
307 return paintBorder;
308 }
309
310
311 /**
312 * Sets the <code>borderPainted</code> property, which is
313 * <code>true</code> if the border should be painted.
314 * The default value for this property is <code>true</code>.
315 * Some look and feels might not implement painted borders;
316 * they will ignore this property.
317 *
318 * @param b if true, the border is painted
319 * @see #isBorderPainted
320 * @beaninfo
321 * description: Does the tool bar paint its borders?
322 * bound: true
323 * expert: true
324 */
325 public void setBorderPainted(boolean b)
326 {
327 if ( paintBorder != b )
328 {
329 boolean old = paintBorder;
330 paintBorder = b;
331 firePropertyChange("borderPainted", old, b);
332 revalidate();
333 repaint();
334 }
335 }
336
337 /**
338 * Paints the tool bar's border if the <code>borderPainted</code> property
339 * is <code>true</code>.
340 *
341 * @param g the <code>Graphics</code> context in which the painting
342 * is done
343 * @see JComponent#paint
344 * @see JComponent#setBorder
359 * @see #setFloatable
360 */
361 public boolean isFloatable()
362 {
363 return floatable;
364 }
365
366 /**
367 * Sets the <code>floatable</code> property,
368 * which must be <code>true</code> for the user to move the tool bar.
369 * Typically, a floatable tool bar can be
370 * dragged into a different position within the same container
371 * or out into its own window.
372 * The default value of this property is <code>true</code>.
373 * Some look and feels might not implement floatable tool bars;
374 * they will ignore this property.
375 *
376 * @param b if <code>true</code>, the tool bar can be moved;
377 * <code>false</code> otherwise
378 * @see #isFloatable
379 * @beaninfo
380 * description: Can the tool bar be made to float by the user?
381 * bound: true
382 * preferred: true
383 */
384 public void setFloatable( boolean b )
385 {
386 if ( floatable != b )
387 {
388 boolean old = floatable;
389 floatable = b;
390
391 firePropertyChange("floatable", old, b);
392 revalidate();
393 repaint();
394 }
395 }
396
397 /**
398 * Returns the current orientation of the tool bar. The value is either
399 * <code>HORIZONTAL</code> or <code>VERTICAL</code>.
400 *
401 * @return an integer representing the current orientation -- either
402 * <code>HORIZONTAL</code> or <code>VERTICAL</code>
403 * @see #setOrientation
404 */
405 public int getOrientation()
406 {
407 return this.orientation;
408 }
409
410 /**
411 * Sets the orientation of the tool bar. The orientation must have
412 * either the value <code>HORIZONTAL</code> or <code>VERTICAL</code>.
413 * If <code>orientation</code> is
414 * an invalid value, an exception will be thrown.
415 *
416 * @param o the new orientation -- either <code>HORIZONTAL</code> or
417 * <code>VERTICAL</code>
418 * @exception IllegalArgumentException if orientation is neither
419 * <code>HORIZONTAL</code> nor <code>VERTICAL</code>
420 * @see #getOrientation
421 * @beaninfo
422 * description: The current orientation of the tool bar
423 * bound: true
424 * preferred: true
425 * enum: HORIZONTAL SwingConstants.HORIZONTAL
426 * VERTICAL SwingConstants.VERTICAL
427 */
428 public void setOrientation( int o )
429 {
430 checkOrientation( o );
431
432 if ( orientation != o )
433 {
434 int old = orientation;
435 orientation = o;
436
437 firePropertyChange("orientation", old, o);
438 revalidate();
439 repaint();
440 }
441 }
442
443 /**
444 * Sets the rollover state of this toolbar. If the rollover state is true
445 * then the border of the toolbar buttons will be drawn only when the
446 * mouse pointer hovers over them. The default value of this property
447 * is false.
448 * <p>
449 * The implementation of a look and feel may choose to ignore this
450 * property.
451 *
452 * @param rollover true for rollover toolbar buttons; otherwise false
453 * @since 1.4
454 * @beaninfo
455 * bound: true
456 * preferred: true
457 * attribute: visualUpdate true
458 * description: Will draw rollover button borders in the toolbar.
459 */
460 public void setRollover(boolean rollover) {
461 putClientProperty("JToolBar.isRollover",
462 rollover ? Boolean.TRUE : Boolean.FALSE);
463 }
464
465 /**
466 * Returns the rollover state.
467 *
468 * @return true if rollover toolbar buttons are to be drawn; otherwise false
469 * @see #setRollover(boolean)
470 * @since 1.4
471 */
472 public boolean isRollover() {
473 Boolean rollover = (Boolean)getClientProperty("JToolBar.isRollover");
474 if (rollover != null) {
475 return rollover.booleanValue();
476 }
477 return false;
478 }
479
819 LayoutManager oldMgr = getLayout();
820 if (oldMgr instanceof PropertyChangeListener) {
821 removePropertyChangeListener((PropertyChangeListener)oldMgr);
822 }
823 super.setLayout(mgr);
824 }
825
826 /////////////////
827 // Accessibility support
828 ////////////////
829
830 /**
831 * Gets the AccessibleContext associated with this JToolBar.
832 * For tool bars, the AccessibleContext takes the form of an
833 * AccessibleJToolBar.
834 * A new AccessibleJToolBar instance is created if necessary.
835 *
836 * @return an AccessibleJToolBar that serves as the
837 * AccessibleContext of this JToolBar
838 */
839 public AccessibleContext getAccessibleContext() {
840 if (accessibleContext == null) {
841 accessibleContext = new AccessibleJToolBar();
842 }
843 return accessibleContext;
844 }
845
846 /**
847 * This class implements accessibility support for the
848 * <code>JToolBar</code> class. It provides an implementation of the
849 * Java Accessibility API appropriate to toolbar user-interface elements.
850 */
851 protected class AccessibleJToolBar extends AccessibleJComponent {
852
853 /**
854 * Get the state of this object.
855 *
856 * @return an instance of AccessibleStateSet containing the current
857 * state set of the object
858 * @see AccessibleState
|
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25 package javax.swing;
26
27 import java.awt.Component;
28 import java.awt.Container;
29 import java.awt.Dimension;
30 import java.awt.Graphics;
31 import java.awt.Insets;
32 import java.awt.LayoutManager;
33 import java.awt.LayoutManager2;
34 import java.beans.JavaBean;
35 import java.beans.BeanProperty;
36 import java.beans.PropertyChangeEvent;
37 import java.beans.PropertyChangeListener;
38
39 import javax.swing.plaf.*;
40 import javax.accessibility.*;
41
42 import java.io.Serializable;
43 import java.io.ObjectOutputStream;
44 import java.io.IOException;
45
46 /**
47 * <code>JToolBar</code> provides a component that is useful for
48 * displaying commonly used <code>Action</code>s or controls.
49 * For examples and information on using tool bars see
50 * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/toolbar.html">How to Use Tool Bars</a>,
51 * a section in <em>The Java Tutorial</em>.
52 *
53 * <p>
54 * With most look and feels,
55 * the user can drag out a tool bar into a separate window
56 * (unless the <code>floatable</code> property is set to <code>false</code>).
57 * For drag-out to work correctly, it is recommended that you add
58 * <code>JToolBar</code> instances to one of the four "sides" of a
59 * container whose layout manager is a <code>BorderLayout</code>,
60 * and do not add children to any of the other four "sides".
61 * <p>
62 * <strong>Warning:</strong> Swing is not thread safe. For more
63 * information see <a
64 * href="package-summary.html#threading">Swing's Threading
65 * Policy</a>.
66 * <p>
67 * <strong>Warning:</strong>
68 * Serialized objects of this class will not be compatible with
69 * future Swing releases. The current serialization support is
70 * appropriate for short term storage or RMI between applications running
71 * the same version of Swing. As of 1.4, support for long term storage
72 * of all JavaBeans™
73 * has been added to the <code>java.beans</code> package.
74 * Please see {@link java.beans.XMLEncoder}.
75 *
76 * @author Georges Saab
77 * @author Jeff Shapiro
78 * @see Action
79 * @since 1.2
80 */
81 @JavaBean(defaultProperty = "UI", description = "A component which displays commonly used controls or Actions.")
82 @SwingContainer
83 @SuppressWarnings("serial") // Same-version serialization only
84 public class JToolBar extends JComponent implements SwingConstants, Accessible
85 {
86 /**
87 * @see #getUIClassID
88 * @see #readObject
89 */
90 private static final String uiClassID = "ToolBarUI";
91
92 private boolean paintBorder = true;
93 private Insets margin = null;
94 private boolean floatable = true;
95 private int orientation = HORIZONTAL;
96
97 /**
98 * Creates a new tool bar; orientation defaults to <code>HORIZONTAL</code>.
99 */
100 public JToolBar()
101 {
102 this( HORIZONTAL );
151 addPropertyChangeListener( layout );
152
153 updateUI();
154 }
155
156 /**
157 * Returns the tool bar's current UI.
158 *
159 * @return the tool bar's current UI.
160 * @see #setUI
161 */
162 public ToolBarUI getUI() {
163 return (ToolBarUI)ui;
164 }
165
166 /**
167 * Sets the L&F object that renders this component.
168 *
169 * @param ui the <code>ToolBarUI</code> L&F object
170 * @see UIDefaults#getUI
171 */
172 @BeanProperty(hidden = true, visualUpdate = true, description
173 = "The UI object that implements the Component's LookAndFeel.")
174 public void setUI(ToolBarUI ui) {
175 super.setUI(ui);
176 }
177
178 /**
179 * Notification from the <code>UIFactory</code> that the L&F has changed.
180 * Called to replace the UI with the latest version from the
181 * <code>UIFactory</code>.
182 *
183 * @see JComponent#updateUI
184 */
185 public void updateUI() {
186 setUI((ToolBarUI)UIManager.getUI(this));
187 // GTKLookAndFeel installs a different LayoutManager, and sets it
188 // to null after changing the look and feel, so, install the default
189 // if the LayoutManager is null.
190 if (getLayout() == null) {
191 setLayout(new DefaultToolBarLayout(getOrientation()));
192 }
193 invalidate();
194 }
195
196
197
198 /**
199 * Returns the name of the L&F class that renders this component.
200 *
201 * @return the string "ToolBarUI"
202 * @see JComponent#getUIClassID
203 * @see UIDefaults#getUI
204 */
205 @BeanProperty(bound = false)
206 public String getUIClassID() {
207 return uiClassID;
208 }
209
210
211 /**
212 * Returns the index of the specified component.
213 * (Note: Separators occupy index positions.)
214 *
215 * @param c the <code>Component</code> to find
216 * @return an integer indicating the component's position,
217 * where 0 is first
218 */
219 public int getComponentIndex(Component c) {
220 int ncomponents = this.getComponentCount();
221 Component[] component = this.getComponents();
222 for (int i = 0 ; i < ncomponents ; i++) {
223 Component comp = component[i];
224 if (comp == c)
225 return i;
240 if ( i >= 0 && i < ncomponents) {
241 Component[] component = this.getComponents();
242 return component[i];
243 }
244 return null;
245 }
246
247 /**
248 * Sets the margin between the tool bar's border and
249 * its buttons. Setting to <code>null</code> causes the tool bar to
250 * use the default margins. The tool bar's default <code>Border</code>
251 * object uses this value to create the proper margin.
252 * However, if a non-default border is set on the tool bar,
253 * it is that <code>Border</code> object's responsibility to create the
254 * appropriate margin space (otherwise this property will
255 * effectively be ignored).
256 *
257 * @param m an <code>Insets</code> object that defines the space
258 * between the border and the buttons
259 * @see Insets
260 */
261 @BeanProperty(expert = true, description
262 = "The margin between the tool bar's border and contents")
263 public void setMargin(Insets m)
264 {
265 Insets old = margin;
266 margin = m;
267 firePropertyChange("margin", old, m);
268 revalidate();
269 repaint();
270 }
271
272 /**
273 * Returns the margin between the tool bar's border and
274 * its buttons.
275 *
276 * @return an <code>Insets</code> object containing the margin values
277 * @see Insets
278 */
279 public Insets getMargin()
280 {
281 if(margin == null) {
282 return new Insets(0,0,0,0);
289 * Gets the <code>borderPainted</code> property.
290 *
291 * @return the value of the <code>borderPainted</code> property
292 * @see #setBorderPainted
293 */
294 public boolean isBorderPainted()
295 {
296 return paintBorder;
297 }
298
299
300 /**
301 * Sets the <code>borderPainted</code> property, which is
302 * <code>true</code> if the border should be painted.
303 * The default value for this property is <code>true</code>.
304 * Some look and feels might not implement painted borders;
305 * they will ignore this property.
306 *
307 * @param b if true, the border is painted
308 * @see #isBorderPainted
309 */
310 @BeanProperty(expert = true, description
311 = "Does the tool bar paint its borders?")
312 public void setBorderPainted(boolean b)
313 {
314 if ( paintBorder != b )
315 {
316 boolean old = paintBorder;
317 paintBorder = b;
318 firePropertyChange("borderPainted", old, b);
319 revalidate();
320 repaint();
321 }
322 }
323
324 /**
325 * Paints the tool bar's border if the <code>borderPainted</code> property
326 * is <code>true</code>.
327 *
328 * @param g the <code>Graphics</code> context in which the painting
329 * is done
330 * @see JComponent#paint
331 * @see JComponent#setBorder
346 * @see #setFloatable
347 */
348 public boolean isFloatable()
349 {
350 return floatable;
351 }
352
353 /**
354 * Sets the <code>floatable</code> property,
355 * which must be <code>true</code> for the user to move the tool bar.
356 * Typically, a floatable tool bar can be
357 * dragged into a different position within the same container
358 * or out into its own window.
359 * The default value of this property is <code>true</code>.
360 * Some look and feels might not implement floatable tool bars;
361 * they will ignore this property.
362 *
363 * @param b if <code>true</code>, the tool bar can be moved;
364 * <code>false</code> otherwise
365 * @see #isFloatable
366 */
367 @BeanProperty(preferred = true, description
368 = "Can the tool bar be made to float by the user?")
369 public void setFloatable( boolean b )
370 {
371 if ( floatable != b )
372 {
373 boolean old = floatable;
374 floatable = b;
375
376 firePropertyChange("floatable", old, b);
377 revalidate();
378 repaint();
379 }
380 }
381
382 /**
383 * Returns the current orientation of the tool bar. The value is either
384 * <code>HORIZONTAL</code> or <code>VERTICAL</code>.
385 *
386 * @return an integer representing the current orientation -- either
387 * <code>HORIZONTAL</code> or <code>VERTICAL</code>
388 * @see #setOrientation
389 */
390 public int getOrientation()
391 {
392 return this.orientation;
393 }
394
395 /**
396 * Sets the orientation of the tool bar. The orientation must have
397 * either the value <code>HORIZONTAL</code> or <code>VERTICAL</code>.
398 * If <code>orientation</code> is
399 * an invalid value, an exception will be thrown.
400 *
401 * @param o the new orientation -- either <code>HORIZONTAL</code> or
402 * <code>VERTICAL</code>
403 * @exception IllegalArgumentException if orientation is neither
404 * <code>HORIZONTAL</code> nor <code>VERTICAL</code>
405 * @see #getOrientation
406 */
407 @BeanProperty(preferred = true, enumerationValues = {
408 "SwingConstants.HORIZONTAL",
409 "SwingConstants.VERTICAL"}, description
410 = "The current orientation of the tool bar")
411 public void setOrientation( int o )
412 {
413 checkOrientation( o );
414
415 if ( orientation != o )
416 {
417 int old = orientation;
418 orientation = o;
419
420 firePropertyChange("orientation", old, o);
421 revalidate();
422 repaint();
423 }
424 }
425
426 /**
427 * Sets the rollover state of this toolbar. If the rollover state is true
428 * then the border of the toolbar buttons will be drawn only when the
429 * mouse pointer hovers over them. The default value of this property
430 * is false.
431 * <p>
432 * The implementation of a look and feel may choose to ignore this
433 * property.
434 *
435 * @param rollover true for rollover toolbar buttons; otherwise false
436 * @since 1.4
437 */
438 @BeanProperty(preferred = true, visualUpdate = true, description
439 = "Will draw rollover button borders in the toolbar.")
440 public void setRollover(boolean rollover) {
441 putClientProperty("JToolBar.isRollover",
442 rollover ? Boolean.TRUE : Boolean.FALSE);
443 }
444
445 /**
446 * Returns the rollover state.
447 *
448 * @return true if rollover toolbar buttons are to be drawn; otherwise false
449 * @see #setRollover(boolean)
450 * @since 1.4
451 */
452 public boolean isRollover() {
453 Boolean rollover = (Boolean)getClientProperty("JToolBar.isRollover");
454 if (rollover != null) {
455 return rollover.booleanValue();
456 }
457 return false;
458 }
459
799 LayoutManager oldMgr = getLayout();
800 if (oldMgr instanceof PropertyChangeListener) {
801 removePropertyChangeListener((PropertyChangeListener)oldMgr);
802 }
803 super.setLayout(mgr);
804 }
805
806 /////////////////
807 // Accessibility support
808 ////////////////
809
810 /**
811 * Gets the AccessibleContext associated with this JToolBar.
812 * For tool bars, the AccessibleContext takes the form of an
813 * AccessibleJToolBar.
814 * A new AccessibleJToolBar instance is created if necessary.
815 *
816 * @return an AccessibleJToolBar that serves as the
817 * AccessibleContext of this JToolBar
818 */
819 @BeanProperty(bound = false)
820 public AccessibleContext getAccessibleContext() {
821 if (accessibleContext == null) {
822 accessibleContext = new AccessibleJToolBar();
823 }
824 return accessibleContext;
825 }
826
827 /**
828 * This class implements accessibility support for the
829 * <code>JToolBar</code> class. It provides an implementation of the
830 * Java Accessibility API appropriate to toolbar user-interface elements.
831 */
832 protected class AccessibleJToolBar extends AccessibleJComponent {
833
834 /**
835 * Get the state of this object.
836 *
837 * @return an instance of AccessibleStateSet containing the current
838 * state set of the object
839 * @see AccessibleState
|