JToolBar: addPropertyChangeListener(PropertyChangeListener listener) : JToolBar « javax.swing « Java by API






JToolBar: addPropertyChangeListener(PropertyChangeListener listener)

  

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.JToolBar: add(JComponent com)
2.JToolBar: addSeparator()
3.JToolBar: getOrientation()
4.JToolBar: isFloatable()
5.JToolBar: setFloatable(boolean b)
6.JToolBar: setRollover(boolean v)