Example usage for java.beans PropertyChangeEvent getPropertyName

List of usage examples for java.beans PropertyChangeEvent getPropertyName

Introduction

In this page you can find the example usage for java.beans PropertyChangeEvent getPropertyName.

Prototype

public String getPropertyName() 

Source Link

Document

Gets the programmatic name of the property that was changed.

Usage

From source file:Main.java

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

    // Register for the event
    LogManager.getLogManager().addPropertyChangeListener(new PropertyChangeListener() {
        // This method is called when configuration file is reread
        public void propertyChange(PropertyChangeEvent evt) {
            String propName = evt.getPropertyName();
            Object oldValue = evt.getOldValue();
            Object newValue = evt.getOldValue();
            // All values are null
        }/*from   w  ww.j a v  a 2 s.  c o  m*/
    });
}

From source file:UsingFocusListener.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextField textField = new JTextField("A TextField");

    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            System.out.println(prop);

        }/* ww  w .  j a v  a2 s  . c o  m*/
    });

    frame.add(textField, "North");
    frame.add(new JTextField(), "South");
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

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");
                }/*from ww  w.  j a  v  a2 s  . c  o m*/
            }
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.FILE_VIEW_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }// w ww. j  a v  a  2  s . c  o  m
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }//www .  ja  v a  2  s.  c o m
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.ACCESSORY_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }/*  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 {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.FILE_HIDING_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }//w  w w  . jav  a 2 s  .  com
        }
    });
}

From source file:Main.java

public static void main(String[] argv) {
    final JFileChooser chooser = new JFileChooser();

    File curDir = chooser.getCurrentDirectory();
    chooser.setDialogTitle("" + curDir.getAbsolutePath());

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                File curDir = chooser.getCurrentDirectory();

                chooser.setDialogTitle("" + curDir.getAbsolutePath());
            }//from  w w w.  j ava  2  s  .  c om
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }/*  w  ww .  ja v a2s  .c om*/
        }
    });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.FILE_FILTER_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

                File curDir = chooser.getCurrentDirectory();
            }/*  w w w . j a va 2 s.  co m*/
        }
    });
}