Example usage for java.beans PropertyChangeEvent getOldValue

List of usage examples for java.beans PropertyChangeEvent getOldValue

Introduction

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

Prototype

public Object getOldValue() 

Source Link

Document

Gets the old value for the property, expressed as an Object.

Usage

From source file:PropertySplitPane.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Property Split");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setContinuousLayout(true);
    splitPane.setOneTouchExpandable(true);

    JComponent topComponent = new JButton("A");
    splitPane.setTopComponent(topComponent);

    JComponent bottomComponent = new JButton("B");
    splitPane.setBottomComponent(bottomComponent);

    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent changeEvent) {
            JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
            String propertyName = changeEvent.getPropertyName();
            if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
                int current = sourceSplitPane.getDividerLocation();
                System.out.println("Current: " + current);
                Integer last = (Integer) changeEvent.getNewValue();
                System.out.println("Last: " + last);
                Integer priorLast = (Integer) changeEvent.getOldValue();
                System.out.println("Prior last: " + priorLast);
            }/*from   w ww .ja  va2  s.co  m*/
        }
    };

    splitPane.addPropertyChangeListener(propertyChangeListener);

    frame.add(splitPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Main.java

public void propertyChange(PropertyChangeEvent evt) {
    Object oldValue = evt.getOldValue();

    Object newValue = evt.getNewValue();
}

From source file:Main.java

public void propertyChange(PropertyChangeEvent evt) {
    Component oldComp = (Component) evt.getOldValue();
    Component newComp = (Component) evt.getNewValue();

    if ("focusOwner".equals(evt.getPropertyName())) {
        if (oldComp == null) {
            System.out.println(newComp.getName());
        } else {/*from   ww  w .  j a va  2  s  . c  o  m*/
            System.out.println(oldComp.getName());
        }
    } else if ("focusedWindow".equals(evt.getPropertyName())) {
        if (oldComp == null) {
            System.out.println(newComp.getName());
        } else {
            System.out.println(oldComp.getName());
        }
    }
}

From source file:Main.java

public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
    Object oldValue = evt.getOldValue();

    Object newValue = evt.getNewValue();

    boolean veto = false;
    if (veto) {/*ww  w .  j a v a  2  s  .c  o  m*/
        throw new PropertyVetoException("the reason for the veto", evt);
    }
}

From source file:Main.java

public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
    Component oldComp = (Component) evt.getOldValue();
    Component newComp = (Component) evt.getNewValue();

    if ("focusOwner".equals(evt.getPropertyName())) {
        if (oldComp == null) {
            System.out.println(newComp.getName());
        } else {//from  w w w  . j  a  v  a2  s. c  o m
            System.out.println(oldComp.getName());
        }
    } else if ("focusedWindow".equals(evt.getPropertyName())) {
        if (oldComp == null) {
            System.out.println(newComp.getName());
        } else {
            System.out.println(oldComp.getName());
        }
    }

    boolean vetoFocusChange = false;
    if (vetoFocusChange) {
        throw new PropertyVetoException("message", evt);
    }
}

From source file:Main.java

public void propertyChange(PropertyChangeEvent evt) {
    System.out.println("Name      = " + evt.getPropertyName());
    System.out.println("Old Value = " + evt.getOldValue());
    System.out.println("New Value = " + evt.getNewValue());
}

From source file:com.eviware.soapui.support.ModelItemPropertyEditorModel.java

public void propertyChange(PropertyChangeEvent evt) {
    fireEditorTextChanged(String.valueOf(evt.getOldValue()), String.valueOf(evt.getNewValue()));
}

From source file:eu.flatworld.worldexplorer.layer.bmng.BMNGHTTPProvider.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
}

From source file:org.rifidi.designer.entities.databinding.ObservableTreeContentProvider.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getOldValue() != null) {
        viewer.remove(evt.getSource(), new Object[] { evt.getOldValue() });
    }/* www . ja v  a2  s . co m*/
    viewer.add(evt.getSource(), evt.getNewValue());
    viewer.refresh(evt.getSource());
}

From source file:AbstractButtonPropertyChangeListener.java

License:asdf

public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    System.out.println("Property Name: " + propertyName);
    if (e.getPropertyName().equals(AbstractButton.TEXT_CHANGED_PROPERTY)) {
        String newText = (String) e.getNewValue();
        String oldText = (String) e.getOldValue();
        System.out.println(oldText + " changed to " + newText);
    } else if (e.getPropertyName().equals(AbstractButton.ICON_CHANGED_PROPERTY)) {
        Icon icon = (Icon) e.getNewValue();
        if (icon instanceof ImageIcon) {
            System.out.println("New icon is an image");
        }//from   w  w  w .j a v a2s.c om
    }
}