Example usage for java.beans PropertyChangeEvent getNewValue

List of usage examples for java.beans PropertyChangeEvent getNewValue

Introduction

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

Prototype

public Object getNewValue() 

Source Link

Document

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

Usage

From source file:Main.java

/**
 * Invoked when task's progress property changes.
 *//* w w w.j  av a  2s.com*/
public void propertyChange(PropertyChangeEvent evt) {
    if ("progress" == evt.getPropertyName()) {
        int progress = (Integer) evt.getNewValue();
        progressBar.setIndeterminate(false);
        progressBar.setValue(progress);
        taskOutput.append(String.format("Completed %d%% of task.\n", progress));
    }
}

From source file:Main.java

public void propertyChange(PropertyChangeEvent evt) {
    if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
        JFileChooser chooser = (JFileChooser) evt.getSource();
        // Get the new selected file
        File newFile = (File) evt.getNewValue();
        repaint();//  w  ww. j  a  va  2s. c o  m
    }
}

From source file:com.anrisoftware.globalpom.exec.core.DefaultCommandExec.java

private PropertyChangeListener[] addTimeoutListener(final ProcessTask task,
        PropertyChangeListener... listeners) {
    return ArrayUtils.add(listeners, new PropertyChangeListener() {

        @Override//  w  w w .j  av  a2  s  .  c  om
        public void propertyChange(PropertyChangeEvent evt) {
            Status status = (Status) evt.getNewValue();
            if (status == Status.TIMEOUT) {
                task.destroy();
            }
        }
    });
}

From source file:ProgressMonitorDemo.java

/**
 * Invoked when task's progress property changes.
 *///from ww w .  j a  v  a 2 s. c  o  m
public void propertyChange(PropertyChangeEvent evt) {
    if ("progress" == evt.getPropertyName()) {
        int progress = (Integer) evt.getNewValue();
        progressMonitor.setProgress(progress);
        String message = String.format("Completed %d%%.\n", progress);
        progressMonitor.setNote(message);
        taskOutput.append(message);
        if (progressMonitor.isCanceled() || task.isDone()) {
            Toolkit.getDefaultToolkit().beep();
            if (progressMonitor.isCanceled()) {
                task.cancel(true);
                taskOutput.append("Task canceled.\n");
            } else {
                taskOutput.append("Task completed.\n");
            }
            startButton.setEnabled(true);
        }
    }

}

From source file:org.polymap.core.mapeditor.tooling.select.LayerSelectableDecorator.java

public void propertyChange(PropertyChangeEvent ev) {
    if (ev.getSource() instanceof SelectionTool) {
        ILayer layer = (ILayer) ev.getNewValue();

        if (ev.getPropertyName().equals(SelectionTool.PROP_LAYER_ACTIVATED)) {
            selectableLayerIds.add(layer.id());
        } else if (ev.getPropertyName().equals(SelectionTool.PROP_LAYER_DEACTIVATED)) {
            selectableLayerIds.remove(layer.id());
        }/*from   w w w . j a  v a  2 s.co  m*/

        Runnable runnable = new Runnable() {
            public void run() {
                // prevent deadlock on close
                if (!PlatformUI.getWorkbench().isClosing()) {
                    fireLabelProviderChanged(new LabelProviderChangedEvent(LayerSelectableDecorator.this));
                }
            }
        };
        if (Display.getCurrent() != null) {
            runnable.run();
        } else {
            Polymap.getSessionDisplay().asyncExec(runnable);
        }
    }
}

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");
        }//www .jav a2 s  . com
    }
}

From source file:org.objectstyle.cayenne.modeler.pref.ComponentGeometry.java

/**
 * Binds this preference object to synchronize its state with a given component
 * property./*from  w  ww.ja  va  2 s .c om*/
 */
public void bindIntProperty(final Component component, final String property, int defaultValue) {

    updateIntProperty(component, property, defaultValue);

    component.addPropertyChangeListener(property, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent e) {
            Object value = e.getNewValue();
            setProperty(property, value != null ? value.toString() : null);
        }
    });
}

From source file:com.facultyshowcase.app.ui.PictureEditor.java

/**
 * Create an instance.//from   w  w  w  . ja v  a2 s .  c  o  m
 */
public PictureEditor() {
    super();
    addClassName("prop");
    _picture.setImageCaching(false);
    _fileField.setAccept("image/*");
    _fileField.addPropertyChangeListener(FileField.PROP_FILE_ITEMS, new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final List<FileItem> files = (List<FileItem>) evt.getNewValue();
            if (files != null && files.size() > 0) {
                _uiValue = files.get(0);
                _picture.setImage(new Image(_uiValue));
                _modified = true;
            }
            _fileField.resetFile();
        }
    });

    final ClassPathResourceLibraryHelper helper = ClassPathResourceLibraryHelper.getInstance();
    _defaultProfilePicture = helper.createResource(helper.createLibrary("default-profile-picture.png"));
}

From source file:com.l2fprod.common.springrcp.JDirectoryChooserBinding.java

protected JComponent doBindControl() {
    component.setSelectedFile((File) getValue());
    component.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            String prop = evt.getPropertyName();
            if (JDirectoryChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) {
                File file = (File) evt.getNewValue();
                controlValueChanged(file);
            }//from  w  w w.j a  v a  2  s . c om
        }
    });
    return component;
}

From source file:Main.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    String strPropertyName = evt.getPropertyName();
    if ("progress".equals(strPropertyName)) {
        progressBar.setIndeterminate(false);
        int progress = (Integer) evt.getNewValue();
        progressBar.setValue(progress);// www.j  a va2 s. c  om
    }
}