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:ProgressBarDemo.java

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

From source file:org.polymap.core.mapeditor.tooling.navi.BackwardEditorAction.java

public void setActiveEditor(IAction _action, IEditorPart _editor) {
    // disconnect old editor
    if (mapEditor != null) {
        try {// ww w.j  a va 2 s  .com
            mapEditor.getMap().removePropertyChangeListener(this);
        } catch (NoSuchEntityException e) {
        }
    }

    action = _action;
    mapEditor = _editor instanceof MapEditor ? (MapEditor) _editor : null;
    if (mapEditor != null) {
        NavigationHistory history = mapEditor.getNaviHistory();
        action.setEnabled(history.canUndo());
        mapEditor.getMap().addPropertyChangeListener(this, new EventFilter<PropertyChangeEvent>() {
            public boolean apply(PropertyChangeEvent ev) {
                String name = ev.getPropertyName();
                return action != null
                        && (IMap.PROP_EXTENT.equals(name) || IMap.PROP_EXTENT_UPDATE.equals(name));
            }
        });
    } else {
        action.setEnabled(false);
    }
}

From source file:Main.java

/**
 * Invoked when task's progress property changes.
 *///from  w  w w.  ja v a2s. 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:org.polymap.core.mapeditor.tooling.navi.ForwardEditorAction.java

public void setActiveEditor(IAction _action, IEditorPart _editor) {
    // disconnect old editor
    if (mapEditor != null) {
        try {/*from   w ww  . j a va2  s.  co  m*/
            mapEditor.getMap().removePropertyChangeListener(this);
        } catch (NoSuchEntityException e) {
        }
    }

    action = _action;
    mapEditor = _editor instanceof MapEditor ? (MapEditor) _editor : null;
    if (mapEditor != null) {
        NavigationHistory history = mapEditor.getNaviHistory();
        action.setEnabled(history.canRedo());
        mapEditor.getMap().addPropertyChangeListener(this, new EventFilter<PropertyChangeEvent>() {
            public boolean apply(PropertyChangeEvent ev) {
                String name = ev.getPropertyName();
                return action != null
                        && (IMap.PROP_EXTENT.equals(name) || IMap.PROP_EXTENT_UPDATE.equals(name));
            }
        });
    } else {
        action.setEnabled(false);
    }
}

From source file:org.nekorp.workflow.desktop.view.binding.SimpleBindableJDateChooser.java

@Override
public void bindListener(final Object target, final String property) {
    listener = new PropertyChangeListener() {
        @Override/*from w  ww  .  j  av  a 2 s  .co  m*/
        public void propertyChange(PropertyChangeEvent evt) {
            try {
                if (StringUtils.equals(evt.getPropertyName(), "date")) {
                    Object value = getModelValue();
                    ignoreUpdate(value);
                    BeanUtils.setProperty(target, property, value);
                }
            } catch (IllegalAccessException | InvocationTargetException ex) {
                SimpleBindableJDateChooser.LOGGER.error("crash", ex);
            }
        }
    };
    this.addPropertyChangeListener(listener);
}

From source file:ProgressMonitorDemo.java

/**
 * Invoked when task's progress property changes.
 *//*from   www . ja va  2  s . co  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:AccessoryFileChooser.java

public void propertyChange(PropertyChangeEvent e) {
    String pname = e.getPropertyName();
    if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(pname)) {
        // Ok, the user selected a file in the chooser
        File f = (File) e.getNewValue();

        // Make reasonably sure it's an audio file
        if ((f != null) && (f.getName().toLowerCase().endsWith(".au")
                || f.getName().toLowerCase().endsWith(".wav") || f.getName().toLowerCase().endsWith(".aif")
                || f.getName().toLowerCase().endsWith(".aiff"))) {
            setCurrentClip(f);//from  w w w. j  a  v  a  2  s  .  com
        } else {
            setCurrentClip(null);
        }
    }
}

From source file:components.ImagePreview.java

public void propertyChange(PropertyChangeEvent e) {
    boolean update = false;
    String prop = e.getPropertyName();

    //If the directory changed, don't show an image.
    if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) {
        file = null;//from   w w w . ja v a2s  .  c om
        update = true;

        //If a file became selected, find out which one.
    } else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) {
        file = (File) e.getNewValue();
        update = true;
    }

    //Update the preview accordingly.
    if (update) {
        thumbnail = null;
        if (isShowing()) {
            loadImage();
            repaint();
        }
    }
}

From source file:wsattacker.plugin.intelligentdos.option.SchemaAnalyzerOption.java

@Override
public void propertyChange(PropertyChangeEvent evt) {
    final String propName = evt.getPropertyName();
    String create = DEFAULT_SOAP_MESSAGE;

    if (CurrentRequest.PROP_WSDLREQUEST.equals(propName)) {

        if (evt.getNewValue() != null) {
            WsdlRequest newRequest = (WsdlRequest) evt.getNewValue();
            create = create(newRequest.getRequestContent());
        }/*from  w  w w .  ja  va2  s  .c  om*/

    } else if (CurrentRequest.PROP_WSDLREQUESTCONTENT.equals(propName)) {
        if (evt.getNewValue() != null) {
            String newContent = (String) evt.getNewValue();
            create = create(newContent);
        }
    } else if (CurrentRequest.PROP_WSDLRESPONSE.equals(propName)
            || CurrentRequest.PROP_WSDLRESPONSECONTENT.equals(propName)) {
        // nothing to do
        return;
    }

    setValue(create);

}

From source file:TapTapTap.java

@Override
public void applyPropertyChange(PropertyChangeEvent pce, JLayer l) {
    if ("tick".equals(pce.getPropertyName())) {
        l.repaint();/*from   w  ww . j  ava  2s . c om*/
    }
}