Example usage for javax.swing.event ChangeListener ChangeListener

List of usage examples for javax.swing.event ChangeListener ChangeListener

Introduction

In this page you can find the example usage for javax.swing.event ChangeListener ChangeListener.

Prototype

ChangeListener

Source Link

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();
    slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JSlider slider = (JSlider) evt.getSource();
            if (!slider.getValueIsAdjusting()) {
                int value = slider.getValue();
                System.out.println(value);
            }/* w w w . j ava 2s .  c  o m*/
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JTabbedPane pane = new JTabbedPane();

    pane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JTabbedPane pane = (JTabbedPane) evt.getSource();

            int sel = pane.getSelectedIndex();
            System.out.println(sel);
        }//from   w w  w  .  j  a  v a  2 s.  c o m
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    MenuSelectionManager.defaultManager().addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            MenuSelectionManager msm = (MenuSelectionManager) evt.getSource();
            MenuElement[] path = msm.getSelectedPath();
            if (path.length == 0) {
            }//w w  w  .  ja va  2 s  .co m
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    MenuSelectionManager.defaultManager().addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            MenuSelectionManager msm = (MenuSelectionManager) evt.getSource();
            MenuElement[] path = msm.getSelectedPath();
            if (path.length == 0) {
            }/*from   w w  w  .  j a  va 2  s  . com*/
        }
    });

}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");

    jb.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
            System.out.println("ChangeEvent!");
        }/*from w  w  w . j a  va2s.c om*/
    });
    ChangeListener[] lis = jb.getChangeListeners();
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");

    jb.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
            System.out.println("ChangeEvent!");
        }/*from   w w  w .j  a v a2  s.c  om*/
    });
    jb.setActionCommand("Bob");

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JButton button = new JButton("ok");
    button.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            DefaultButtonModel model = (DefaultButtonModel) button.getModel();
            if (model.isEnabled())
                System.out.println("Enabled: true");
            else/*from  w w  w  .j  ava  2s. c  om*/
                System.out.println("Enabled: false");

            if (model.isArmed())
                System.out.println("Armed: true");
            else
                System.out.println("Armed: false");

            if (model.isPressed())
                System.out.println("Pressed: true");
            else
                System.out.println("Pressed: false");
        }
    });
    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");

    jb.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
            System.out.println("ChangeEvent!");
        }/*  w  w w.  j a  va2s. c o  m*/
    });
    jb.setVerticalAlignment(20);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");

    jb.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
            System.out.println("ChangeEvent!");
        }//from w w w. ja v  a 2  s.co m
    });
    jb.setText("new text");

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");

    jb.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
            System.out.println("ChangeEvent!");
        }//w w w.j a  va2s  .c o m
    });
    jb.setVerticalTextPosition(20);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}