![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e817. Determining When a Floatable JToolBar Container Changes OrientationWhen the orientation of a toolbar is changed, either by the user or programmatically, the toolbar fires a property change event.// Create a floatable horizontal toolbar JToolBar toolbar = new JToolBar(); // Register for orientation property change events toolbar.addPropertyChangeListener(new java.beans.PropertyChangeListener() { // This method is called whenever the orientation of the toolbar is changed public void propertyChange(java.beans.PropertyChangeEvent evt) { String propName = evt.getPropertyName(); if ("orientation".equals(propName)) { // Get the old orientation Integer oldValue = (Integer)evt.getOldValue(); // Get the new orientation Integer newValue = (Integer)evt.getNewValue(); if (newValue.intValue() == JToolBar.HORIZONTAL) { // toolbar now has horizontal orientation } else { // toolbar now has vertical orientation } } } });
e818. Preventing a JToolbar Container from Floating e819. Highlighting Buttons in a JToolbar Container While Under the Cursor © 2002 Addison-Wesley. |