Determining When a Floatable JToolBar Container Changes Orientation : Toolbar « Swing JFC « Java






Determining When a Floatable JToolBar Container Changes Orientation

    
import javax.swing.JToolBar;

public class Main {
  public static void main(String[] argv) throws Exception {
    JToolBar toolbar = new JToolBar();
    toolbar.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
      public void propertyChange(java.beans.PropertyChangeEvent evt) {
        String propName = evt.getPropertyName();
        if ("orientation".equals(propName)) {
          Integer oldValue = (Integer) evt.getOldValue();
          Integer newValue = (Integer) evt.getNewValue();
          if (newValue.intValue() == JToolBar.HORIZONTAL) {
            System.out.println("horizontal orientation");
          } else {
            System.out.println("vertical orientation");
          }
        }
      }
    });
  }
}

   
    
    
    
  








Related examples in the same category

1.Create two toolbars
2.Shows a vertical toolbar.
3.A simple frame containing a toolbar made up of several ButtonsA simple frame containing a toolbar made up of several Buttons
4.An example of JToolBarAn example of JToolBar
5.Toolbar SampleToolbar Sample
6.JToolBar DemoJToolBar Demo
7.Swing ToolBar DemoSwing ToolBar Demo
8.ToolBar Demo 2ToolBar Demo 2
9.Toolbar and menubarToolbar and menubar
10.Simple toolbarSimple toolbar
11.Working with a ToolbarWorking with a Toolbar
12.Get ToolBar PropertiesGet ToolBar Properties
13.If the toolbar is to be floatable, it must be added to a container with a BorderLayout.
14.Highlighting Buttons in a JToolbar Container While Under the Cursor
15.JToolbar: Toolbars provide a quick access to the most frequently used commands.JToolbar: Toolbars provide a quick access to the most frequently used commands.
16.Preventing a JToolbar Container from Floating
17.Create a vertical toolbar
18.Add various buttons to the toolbar
19.ToolBar UI SampleToolBar UI Sample
20.ToolBar button
21.This class represents a separator for the toolbar buttons.
22.Buttons used in toolbars.
23.A frame with a toolbar and menu for color changesA frame with a toolbar and menu for color changes