Example usage for java.beans PropertyChangeEvent getSource

List of usage examples for java.beans PropertyChangeEvent getSource

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

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.ACCEPT_ALL_FILE_FILTER_USED_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 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.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldDir = (File) evt.getOldValue();
                File newDir = (File) evt.getNewValue();

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

From source file:Main.java

public static void main(String[] argv) {

    JFileChooser chooser = new JFileChooser();

    chooser.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File oldFile = (File) evt.getOldValue();
                File newFile = (File) evt.getNewValue();

                System.out.println(oldFile);
                System.out.println(newFile);
                System.out.println(chooser.getSelectedFile());
            } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
                JFileChooser chooser = (JFileChooser) evt.getSource();
                File[] oldFiles = (File[]) evt.getOldValue();
                File[] newFiles = (File[]) evt.getNewValue();

                Arrays.toString(oldFiles);
                Arrays.toString(newFiles);
                File[] files = chooser.getSelectedFiles();
                Arrays.toString(files);
            }/*w  w  w . jav  a  2  s .c o m*/
        }
    });

    chooser.setVisible(true);

}

From source file:com.anrisoftware.prefdialog.miscswing.actions.AbstractAppActionListener.java

/**
 * Returns the future task from the property change event.
 *
 * @param evt//from  w ww. j a v  a  2  s  .  c  o  m
 *            the {@link PropertyChangeEvent} that have the source set to
 *            the future task.
 *
 * @return the {@link Future} task.
 *
 * @since 3.6
 */
@SuppressWarnings("unchecked")
public static <T> Future<T> asFuture(PropertyChangeEvent evt) {
    return (Future<T>) evt.getSource();
}

From source file:Main.java

public void propertyChange(PropertyChangeEvent e) {
    Object source = e.getSource();
    if (source == amountField) {
        amount = ((Number) amountField.getValue()).doubleValue();
        System.out.println("amount = " + amount);
        amountField.setValue(amount);/*  w w  w .ja  v  a 2  s  .c  o  m*/
    }
}

From source file:org.polymap.p4.fs.WorkbenchState.java

public static void startup() {
    new Job("WorkbenchState.startup") {
        protected IStatus run(IProgressMonitor monitor) {
            log.info("Installing listener...");
            // mapListener
            EventManager.instance().subscribe(
                    // listener
                    mapListener = new Object() {
                        @EventHandler(scope = Event.Scope.JVM)
                        protected void handleEvent(final PropertyChangeEvent ev) {
                            final SessionContext session = EventManager.publishSession();
                            session.execute(new Runnable() {
                                public void run() {
                                    WorkbenchState state = WorkbenchState.instance(session);
                                    state.handleEvent(ev);
                                }/*from w ww .  ja  va  2s.com*/
                            });
                        }
                    },
                    // filter
                    new EventFilter<PropertyChangeEvent>() {
                        public boolean apply(PropertyChangeEvent ev) {
                            SessionContext session = EventManager.publishSession();
                            return session != null && !session.isDestroyed() && ev.getSource() instanceof IMap;
                        }
                    });
            // featureListener
            EventManager.instance().subscribe(
                    // listener
                    featureListener = new Object() {
                        @EventHandler(scope = Event.Scope.JVM)
                        protected void handleEvent(final FeatureSelectionEvent ev) {
                            final SessionContext session = EventManager.publishSession();
                            session.execute(new Runnable() {
                                public void run() {
                                    WorkbenchState state = WorkbenchState.instance(session);
                                    state.handleEvent(ev);
                                }
                            });
                        }
                    },
                    // filter
                    new EventFilter<FeatureSelectionEvent>() {
                        public boolean apply(FeatureSelectionEvent ev) {
                            SessionContext session = EventManager.publishSession();
                            return session != null && !session.isDestroyed();
                        }
                    });
            return Status.OK_STATUS;
        }
    }.schedule(10000);
}

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();//  www.j  av a 2  s .  c o m
    }
}

From source file:org.lunifera.runtime.common.state.impl.GlobalDataState.java

/**
 * Puts the object into the dirty state.
 * //  w w  w .  j  ava  2 s.  co  m
 * @param event
 */
protected void handleDirty(PropertyChangeEvent event) {
    Object object = event.getSource();
    Class<?> objClass = object.getClass();

    sharedStateContext.handleDirty(HashUtil.createObjectWithIdHash(objClass, object), object);
}

From source file:org.lunifera.runtime.common.state.impl.GlobalDataState.java

/**
 * Invalidates the object in the cache./*from w  w  w .  ja v  a2s.c o  m*/
 * 
 * @param event
 */
protected void handleDispose(PropertyChangeEvent event) {
    Object object = event.getSource();
    Class<?> objClass = object.getClass();

    sharedStateContext.invalidate(HashUtil.createObjectWithIdHash(objClass, object), object);
}

From source file:org.lunifera.runtime.common.state.impl.GlobalDataState.java

@Override
public void propertyChange(PropertyChangeEvent event) {
    Object object = event.getSource();
    Class<?> objClass = object.getClass();
    try {//from  ww w  .j ava  2 s .  c  om
        if (DtoUtils.isDisposeField(objClass, event.getPropertyName())) {
            handleDispose(event);
            return;
        }
    } catch (SecurityException ignoreIt) {
        LOGGER.error("{}", ignoreIt);
    }

    handleDirty(event);
}