Java Code Examples for java.beans.PropertyChangeEvent#getPropertyName()

The following examples show how to use java.beans.PropertyChangeEvent#getPropertyName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanContextSupport.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * subclasses may envelope to monitor veto child property changes.
 */

public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException {
    String propertyName = pce.getPropertyName();
    Object source       = pce.getSource();

    synchronized(children) {
        if ("beanContext".equals(propertyName) &&
            containsKey(source)                    &&
            !getBeanContextPeer().equals(pce.getNewValue())
        ) {
            if (!validatePendingRemove(source)) {
                throw new PropertyVetoException("current BeanContext vetoes setBeanContext()", pce);
            } else ((BCSChild)children.get(source)).setRemovePending(true);
        }
    }
}
 
Example 2
Source File: BeanContextSupport.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * subclasses may envelope to monitor child property changes.
 */

public void propertyChange(PropertyChangeEvent pce) {
    String propertyName = pce.getPropertyName();
    Object source       = pce.getSource();

    synchronized(children) {
        if ("beanContext".equals(propertyName) &&
            containsKey(source)                    &&
            ((BCSChild)children.get(source)).isRemovePending()) {
            BeanContext bc = getBeanContextPeer();

            if (bc.equals(pce.getOldValue()) && !bc.equals(pce.getNewValue())) {
                remove(source, false);
            } else {
                ((BCSChild)children.get(source)).setRemovePending(false);
            }
        }
    }
}
 
Example 3
Source File: FileChooserDemo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if (SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) {
        if (isShowing()) {
            loadImage((File) e.getNewValue());
            repaint();
        }
    }
}
 
Example 4
Source File: BasicScrollPaneUI.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void scrollPanePropertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();

    if (propertyName == "verticalScrollBarDisplayPolicy") {
        updateScrollBarDisplayPolicy(e);
    }
    else if (propertyName == "horizontalScrollBarDisplayPolicy") {
        updateScrollBarDisplayPolicy(e);
    }
    else if (propertyName == "viewport") {
        updateViewport(e);
    }
    else if (propertyName == "rowHeader") {
        updateRowHeader(e);
    }
    else if (propertyName == "columnHeader") {
        updateColumnHeader(e);
    }
    else if (propertyName == "verticalScrollBar") {
        updateVerticalScrollBar(e);
    }
    else if (propertyName == "horizontalScrollBar") {
        updateHorizontalScrollBar(e);
    }
    else if (propertyName == "componentOrientation") {
        scrollpane.revalidate();
        scrollpane.repaint();
    }
}
 
Example 5
Source File: NimbusLookAndFeel.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override public void propertyChange(PropertyChangeEvent ev) {
    String key = ev.getPropertyName();
    if ("UIDefaults".equals(key)) {
        compiledDefaults = null;
    } else {
        addDefault(key, ev.getNewValue());
    }
}
 
Example 6
Source File: BasicScrollPaneUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void scrollPanePropertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();

    if (propertyName == "verticalScrollBarDisplayPolicy") {
        updateScrollBarDisplayPolicy(e);
    }
    else if (propertyName == "horizontalScrollBarDisplayPolicy") {
        updateScrollBarDisplayPolicy(e);
    }
    else if (propertyName == "viewport") {
        updateViewport(e);
    }
    else if (propertyName == "rowHeader") {
        updateRowHeader(e);
    }
    else if (propertyName == "columnHeader") {
        updateColumnHeader(e);
    }
    else if (propertyName == "verticalScrollBar") {
        updateVerticalScrollBar(e);
    }
    else if (propertyName == "horizontalScrollBar") {
        updateHorizontalScrollBar(e);
    }
    else if (propertyName == "componentOrientation") {
        scrollpane.revalidate();
        scrollpane.repaint();
    }
}
 
Example 7
Source File: ImageFileChooser.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void propertyChange(PropertyChangeEvent event) {
	final String prop = event.getPropertyName();
	if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop) && isShowing()) {
		try {
			loadImage((File) event.getNewValue());
			repaint();
		} catch (final IOException ex) {
			MSwingUtilities.showException(ex);
		}
	}
}
 
Example 8
Source File: JTopPlugin.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent ev) {
    String prop = ev.getPropertyName();
    if (prop == JConsoleContext.CONNECTION_STATE_PROPERTY) {
        ConnectionState newState = (ConnectionState)ev.getNewValue();
        // JConsole supports disconnection and reconnection
        // The MBeanServerConnection will become invalid when
        // disconnected. Need to use the new MBeanServerConnection object
        // created at reconnection time.
        if (newState == ConnectionState.CONNECTED && jtop != null) {
            jtop.setMBeanServerConnection(
                getContext().getMBeanServerConnection());
        }
    }
}
 
Example 9
Source File: SwingSet3.java    From littleluck with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    if (propertyName.equals("demoComponent")) {
        Demo demo = (Demo)e.getSource();
        JComponent demoComponent = (JComponent)e.getNewValue();
        if (demoComponent != null) {
            demoComponent.putClientProperty("swingset3.demo", demo);
            demoComponent.addHierarchyListener(new DemoVisibilityListener());
            registerPopups(demoComponent);
        }
    } 
}
 
Example 10
Source File: PresenterEditorAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    String propertyName = evt.getPropertyName();
    if (SELECTED_KEY.equals(propertyName)) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("propertyChange() of SELECTED_KEY for action " + actionName);
        }
        updateSelectedInPresenters();
    }
    // Re-fire the property change
    firePropertyChange(propertyName, null, null);
}
 
Example 11
Source File: JScrollPane.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method gets called when a bound property is changed.
 * @param e A <code>PropertyChangeEvent</code> object describing
 * the event source and the property that has changed. Must not be null.
 *
 * @throws NullPointerException if the parameter is null.
 * @since 1.5
 */
public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    if (propertyName == "horizontalScrollBar" ||
        propertyName == "verticalScrollBar") {

        if (e.getNewValue() instanceof JScrollBar) {
            setScrollBarRelations((JScrollBar)e.getNewValue());
        }
    }
}
 
Example 12
Source File: JComboBox.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    if (e.getPropertyName() == "editor") {
        // set the combo box editor's accessible name
        // and description
        setEditorNameAndDescription();
    }
}
 
Example 13
Source File: DomTC.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a page inspector listener.
 * 
 * @return page inspector listener.
 */
private PropertyChangeListener createInspectorListener() {
    return new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            String propName = evt.getPropertyName();
            if (PageInspectorImpl.PROP_MODEL.equals(propName)) {
                update();
            }
        }
    };
}
 
Example 14
Source File: WebPersistenceProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
    String propName = event.getPropertyName();
    if (propName == null || propName.equals(WebProjectProperties.PERSISTENCE_XML_DIR)) {
        locationChanged();
    }
}
 
Example 15
Source File: JList.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Property Change Listener change method. Used to track changes
 * to the DataModel and ListSelectionModel, in order to re-set
 * listeners to those for reporting changes there via the Accessibility
 * PropertyChange mechanism.
 *
 * @param e PropertyChangeEvent
 */
public void propertyChange(PropertyChangeEvent e) {
    String name = e.getPropertyName();
    Object oldValue = e.getOldValue();
    Object newValue = e.getNewValue();

        // re-set listData listeners
    if (name.compareTo("model") == 0) {

        if (oldValue != null && oldValue instanceof ListModel) {
            ((ListModel) oldValue).removeListDataListener(this);
        }
        if (newValue != null && newValue instanceof ListModel) {
            ((ListModel) newValue).addListDataListener(this);
        }

        // re-set listSelectionModel listeners
    } else if (name.compareTo("selectionModel") == 0) {

        if (oldValue != null && oldValue instanceof ListSelectionModel) {
            ((ListSelectionModel) oldValue).removeListSelectionListener(this);
        }
        if (newValue != null && newValue instanceof ListSelectionModel) {
            ((ListSelectionModel) newValue).addListSelectionListener(this);
        }

        firePropertyChange(
            AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
            Boolean.valueOf(false), Boolean.valueOf(true));
    }
}
 
Example 16
Source File: BasicProgressBarUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if ("indeterminate" == prop) {
        if (progressBar.isIndeterminate()) {
            initIndeterminateValues();
        } else {
            //clean up
            cleanUpIndeterminateValues();
        }
        progressBar.repaint();
    }
}
 
Example 17
Source File: DefaultTableColumnModel.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Property Change Listener change method.  Used to track changes
 * to the column width or preferred column width.
 *
 * @param  evt  <code>PropertyChangeEvent</code>
 */
public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();

    if (name == "width" || name == "preferredWidth") {
        invalidateWidthCache();
        // This is a misnomer, we're using this method
        // simply to cause a relayout.
        fireColumnMarginChanged();
    }

}
 
Example 18
Source File: NimbusLookAndFeel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override public void propertyChange(PropertyChangeEvent ev) {
    String key = ev.getPropertyName();
    if ("UIDefaults".equals(key)) {
        compiledDefaults = null;
    } else {
        addDefault(key, ev.getNewValue());
    }
}
 
Example 19
Source File: FileEntryNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Support for firing property change.
 *
 * @param ev event describing the change
 */
void fireChange (PropertyChangeEvent ev) {
    String propertyName = ev.getPropertyName();
    if (propertyName.equals(Node.PROP_COOKIE)) {
        fireCookieChange();
        return;
    }
    // dataobject may have a property that this node does not have
    if (hasProperty(propertyName)) {
        firePropertyChange(propertyName, ev.getOldValue(), ev.getNewValue());
    }
    if (propertyName.equals(DataObject.PROP_NAME)) {
        super.setName (entry.getName ());
    }
}
 
Example 20
Source File: ProgressMonitor.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * This method gets called when a bound property is changed.
 *
 * @param e A <code>PropertyChangeEvent</code> object describing
 * the event source and the property that has changed. Must not be null.
 * @throws NullPointerException if the parameter is null.
 */
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == noteLabel && e.getPropertyName() == "text") {
        // the note label text changed
        firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, 0);
    }
}