Java Code Examples for java.beans.PropertyChangeEvent

The following examples show how to use java.beans.PropertyChangeEvent. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
protected void installListeners(final AbstractButton b) {
    super.installListeners(b);

    this.stateTransitionTracker.registerModelListeners();
    this.stateTransitionTracker.registerFocusListeners();

    this.substancePropertyListener = (PropertyChangeEvent evt) -> {
        if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
            stateTransitionTracker.setModel((ButtonModel) evt.getNewValue());
        }
        if ("font".equals(evt.getPropertyName())) {
            SwingUtilities.invokeLater(b::updateUI);
        }
    };
    b.addPropertyChangeListener(substancePropertyListener);
}
 
Example 2
Source Project: netbeans   Source File: BaseActionProvider.java    License: Apache License 2.0 6 votes vote down vote up
public BaseActionProvider(Project project, UpdateHelper updateHelper, PropertyEvaluator evaluator, 
        SourceRoots sourceRoots, SourceRoots testRoots, AntProjectHelper antProjectHelper, Callback callback) {
    this.antProjectHelper = antProjectHelper;
    this.callback = callback;
    this.classpaths = (id) -> getCallback().getProjectSourcesClassPath(id);
    this.updateHelper = updateHelper;
    this.project = project;
    this.evaluator = evaluator;
    this.projectSourceRoots = sourceRoots;
    this.projectTestRoots = testRoots;
    this.evaluator.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            synchronized (BaseActionProvider.class) {
                final String propName = evt.getPropertyName();
                if (propName == null || BUILD_SCRIPT.equals(propName)) {
                    buildXMLName = null;
                }
            }
        }
    });
    this.listeners = Collections.singletonList(new EventAdaptor());
    this.delegate = new AtomicReference<>();
}
 
Example 3
Source Project: netbeans   Source File: EditorRegistry.java    License: Apache License 2.0 6 votes vote down vote up
private synchronized static void _focusGained(JTextComponent c, Component origFocused, List<PropertyChangeEvent> events) {
    Item item = item(c);
    assert (item != null) : "Not registered!"; // NOI18N

    // Move the item to head of the list
    removeFromItemList(item);
    addToItemListAsFirst(item);
    item.focused = true;

    c.addPropertyChangeListener(PropertyDocL.INSTANCE);
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, FOCUS_GAINED_PROPERTY + ": " + dumpComponent(c) + '\n'); //NOI18N
        logItemListFinest();
    }
    if (c == origFocused) {
        origFocused = null;
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("has equal components, using origFocused = "+origFocused);
        }
    }
    events.add(new PropertyChangeEvent(EditorRegistry.class, FOCUS_GAINED_PROPERTY, origFocused, c));
}
 
Example 4
Source Project: jdk8u_jdk   Source File: EnumEditor.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void setValue( Object value ) {
    if ( ( value != null ) && !this.type.isInstance( value ) ) {
        throw new IllegalArgumentException( "Unsupported value: " + value );
    }
    Object oldValue;
    PropertyChangeListener[] listeners;
    synchronized ( this.listeners ) {
        oldValue = this.value;
        this.value = value;

        if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
            return; // do not fire event if value is not changed
        }
        int size = this.listeners.size();
        if ( size == 0 ) {
            return; // do not fire event if there are no any listener
        }
        listeners = this.listeners.toArray( new PropertyChangeListener[size] );
    }
    PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
    for ( PropertyChangeListener listener : listeners ) {
        listener.propertyChange( event );
    }
}
 
Example 5
Source Project: netbeans   Source File: SectionNodePanel.java    License: Apache License 2.0 6 votes vote down vote up
public SectionNodePanel(final SectionNode node, boolean openFirstChild) {
    super(node.getSectionNodeView(), node, node.getDisplayName(), node);
    this.openFirstChild = openFirstChild;
    
    if (node.getKey() instanceof SectionView) {
        // the section corresponding to the top level node is always expanded
        setInnerViewMode();
    } else if (node.isExpanded()) {
        setExpandedViewMode();
    }
    node.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (Node.PROP_DISPLAY_NAME.equals(evt.getPropertyName())) {
                setTitle(node.getDisplayName());
            }
        }
    });
}
 
Example 6
Source Project: Sparkplug   Source File: MainActivity.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
@Override
public void propertyChange(PropertyChangeEvent event) {

    if (!event.getPropertyName().equals(ActivityConstants.ConnectionStatusProperty)) {
        return;
    }
    mainActivity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            mainActivity.drawerFragment.notifyDataSetChanged();
        }

    });

}
 
Example 7
Source Project: pgptool   Source File: DecryptOnePm.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
	boolean result = isUseBrowseFolder.getValue();
	actionBrowseTarget.setEnabled(result);
	targetFileEnabled.setValueByOwner(result);
	// NOTE: MAGIC: This event might be triggered when using suggested
	// parameters. So if value is already provided for target file then
	// we'll not show file chooser
	if (result && !StringUtils.hasText(targetFile.getValue())) {
		getTargetFileChooser().askUserForFile(UiUtils.actionEvent(evt));
	}

	if (!result) {
		clearValidationErrorsFromTargetFile();
	}
}
 
Example 8
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    JInternalFrame f = (JInternalFrame)evt.getSource();
    boolean value = false;
    if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
        repaint();
    } else if (prop.equals("maximizable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(maximizeButton);
        else
            remove(maximizeButton);
        revalidate();
        repaint();
    } else if (prop.equals("iconable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(minimizeButton);
        else
            remove(minimizeButton);
        revalidate();
        repaint();
    } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
        repaint();
    }
    enableActions();
}
 
Example 9
Source Project: ramus   Source File: IDEF0TabView.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (Action.SELECTED_KEY.equals(evt.getPropertyName())) {
        if ((Boolean) evt.getNewValue()) {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Image image = toolkit.getImage(getClass()
                    .getResource("/images/pen-cursor.png"));
            java.awt.Point point = new java.awt.Point(0, 15);
            panel.getMovingArea().setVisualCopyCursor(
                    toolkit.createCustomCursor(image, point,
                            "CopyVisualCursor"));
        } else {
            panel.getMovingArea().setVisualCopyCursor(null);
        }
    }
}
 
Example 10
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    JInternalFrame f = (JInternalFrame)evt.getSource();
    boolean value = false;
    if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
        repaint();
    } else if (prop.equals("maximizable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(maximizeButton);
        else
            remove(maximizeButton);
        revalidate();
        repaint();
    } else if (prop.equals("iconable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(minimizeButton);
        else
            remove(minimizeButton);
        revalidate();
        repaint();
    } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
        repaint();
    }
    enableActions();
}
 
Example 11
Source Project: pumpernickel   Source File: SummonMenuItem.java    License: MIT License 6 votes vote down vote up
/**
 * Create a new <code>SummonMenuItem</code>.
 * 
 * @param f
 *            the frame to bring to front when this menu item is activated
 */
public SummonMenuItem(Frame f) {
	super();
	frame = f;
	addActionListener(actionListener);
	updateText();

	frame.addPropertyChangeListener("title", new PropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent e) {
			updateText();
		}
	});

	// this UI is buggy, and has issues.
	// the main issue is that it won't even show up on Macs
	// if you use the screen menubar, and since the goal
	// is to emulate macs: why bother?
	// if(frame instanceof JFrame)
	// setUI(new FrameMenuItemUI((JFrame)frame));
}
 
Example 12
/**
 * Invoked when a property changes. We are only interested in when the
 * Document changes to reset the DocumentListener.
 */
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == getEditor() && e.getPropertyName().equals(
            "document")) {
        Document oldDoc = (Document) e.getOldValue();
        Document newDoc = (Document) e.getNewValue();

        // Reset the DocumentListener
        oldDoc.removeDocumentListener(this);
        newDoc.addDocumentListener(this);

        // Recreate the TreeModel.
        treeModel = new ElementTreeModel(newDoc);
        tree.setModel(treeModel);
    }
}
 
Example 13
Source Project: jdk8u-jdk   Source File: BasicScrollPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void sbPropertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    Object source = e.getSource();

    if ("model" == propertyName) {
        JScrollBar sb = scrollpane.getVerticalScrollBar();
        BoundedRangeModel oldModel = (BoundedRangeModel)e.
                             getOldValue();
        ChangeListener cl = null;

        if (source == sb) {
            cl = vsbChangeListener;
        }
        else if (source == scrollpane.getHorizontalScrollBar()) {
            sb = scrollpane.getHorizontalScrollBar();
            cl = hsbChangeListener;
        }
        if (cl != null) {
            if (oldModel != null) {
                oldModel.removeChangeListener(cl);
            }
            if (sb.getModel() != null) {
                sb.getModel().addChangeListener(cl);
            }
        }
    }
    else if ("componentOrientation" == propertyName) {
        if (source == scrollpane.getHorizontalScrollBar()) {
            JScrollBar hsb = scrollpane.getHorizontalScrollBar();
            JViewport viewport = scrollpane.getViewport();
            Point p = viewport.getViewPosition();
            if (scrollpane.getComponentOrientation().isLeftToRight()) {
                p.x = hsb.getValue();
            } else {
                p.x = viewport.getViewSize().width - viewport.getExtentSize().width - hsb.getValue();
            }
            viewport.setViewPosition(p);
        }
    }
}
 
Example 14
Source Project: TencentKona-8   Source File: CTrayIcon.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    if (messageDialog == null) {
        return;
    }

    String prop = e.getPropertyName();
    Container cp = messageDialog.getContentPane();

    if (messageDialog.isVisible() && e.getSource() == cp &&
            (prop.equals(JOptionPane.VALUE_PROPERTY))) {
        disposeMessageDialog();
    }
}
 
Example 15
Source Project: jdk8u60   Source File: FilePane.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
        if (viewType == -1) {
            setViewType(VIEWTYPE_LIST);
        }

    String s = e.getPropertyName();
    if (s.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
        doSelectedFileChanged(e);
    } else if (s.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
        doSelectedFilesChanged(e);
    } else if (s.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
        doDirectoryChanged(e);
    } else if (s.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
        doFilterChanged(e);
    } else if (s.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
        doFileSelectionModeChanged(e);
    } else if (s.equals(JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) {
        doMultiSelectionChanged(e);
    } else if (s.equals(JFileChooser.CANCEL_SELECTION)) {
        applyEdit();
    } else if (s.equals("busy")) {
        setCursor((Boolean)e.getNewValue() ? waitCursor : null);
    } else if (s.equals("componentOrientation")) {
        ComponentOrientation o = (ComponentOrientation)e.getNewValue();
        JFileChooser cc = (JFileChooser)e.getSource();
        if (o != e.getOldValue()) {
            cc.applyComponentOrientation(o);
        }
        if (detailsTable != null) {
            detailsTable.setComponentOrientation(o);
            detailsTable.getParent().getParent().setComponentOrientation(o);
        }
    }
}
 
Example 16
Source Project: netbeans   Source File: ProxyNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent pce) {
    if (nodeListener) {
        nodePropertyChange(pce);
    } else {
        realPropertyChange(pce);
    }
}
 
Example 17
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JColorChooser)e.getSource());
    }
}
 
Example 18
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    if( prop.equals(JInternalFrame.IS_SELECTED_PROPERTY) ) {
        Boolean b = (Boolean)evt.getNewValue();
        iconButton.putClientProperty("paintActive", b);
        closeButton.putClientProperty("paintActive", b);
        maxButton.putClientProperty("paintActive", b);
    }
    else if ("JInternalFrame.messageType".equals(prop)) {
        updateOptionPaneState();
        frame.repaint();
    }
    super.propertyChange(evt);
}
 
Example 19
Source Project: netbeans   Source File: CreateTag.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (selectButton != null && ChangesetPickerSimplePanel.PROP_VALID.equals(evt.getPropertyName())) {
        boolean valid = (Boolean) evt.getNewValue();
        selectButton.setEnabled(valid);
    }
}
 
Example 20
public void propertyChange(PropertyChangeEvent e)
{
    String name = e.getPropertyName();
    if ( name.equals( FREE_STANDING_PROP ) )
    {
        handlePropertyChange( e.getNewValue() );
    }
    else {
        super.propertyChange( e );
    }
}
 
Example 21
Source Project: netbeans   Source File: CustomizerDisplay.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    super.propertyChange(evt);
    if (SingleModuleProperties.NB_PLATFORM_PROPERTY.equals(evt.getPropertyName())) {
        fillUpCategoryValue();
    }
}
 
Example 22
Source Project: netbeans   Source File: VersioningPanelController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange (PropertyChangeEvent evt) {
    if (FileStatusCache.PROP_FILE_STATUS_CHANGED.equals(evt.getPropertyName())) {
        FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) evt.getNewValue();
        if (affectsView((FileStatusCache.ChangedEvent) evt.getNewValue())) {
            applyChange(changedEvent);
        }
    }
}
 
Example 23
Source Project: jdk1.8-source-analysis   Source File: JFileChooser.java    License: Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent ev) {
    assert ev.getPropertyName().equals(SHOW_HIDDEN_PROP);
    JFileChooser jfc = jfcRef.get();
    if (jfc == null) {
        // Our JFileChooser is no longer around, so we no longer need to
        // listen for PropertyChangeEvents.
        Toolkit.getDefaultToolkit().removePropertyChangeListener(SHOW_HIDDEN_PROP, this);
    }
    else {
        boolean oldValue = jfc.useFileHiding;
        jfc.useFileHiding = !((Boolean)ev.getNewValue()).booleanValue();
        jfc.firePropertyChange(FILE_HIDING_CHANGED_PROPERTY, oldValue, jfc.useFileHiding);
    }
}
 
Example 24
Source Project: netbeans   Source File: BootClassPathImplementation.java    License: Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (GrailsProjectConfig.GRAILS_JAVA_PLATFORM_PROPERTY.equals(evt.getPropertyName())
            || GrailsProjectConfig.GRAILS_PLATFORM_PROPERTY.equals(evt.getPropertyName())) {

        LOGGER.log(Level.FINE, "Boot classpath changed due to change in {0}", evt.getPropertyName());

        synchronized (BootClassPathImplementation.this) {
            resourcesCache = null;
            eventId++;
        }
        support.firePropertyChange(ClassPathImplementation.PROP_RESOURCES, null, null);
    }
}
 
Example 25
Source Project: ghidra   Source File: CachingSwingWorker.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent event) {
	if ("state".equals(event.getPropertyName()) &&
		SwingWorker.StateValue.DONE == event.getNewValue()) {
		dialog.close();
	}
}
 
Example 26
Source Project: netbeans   Source File: DatabaseConnectionTest.java    License: Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(DatabaseConnection.PROP_DRIVER)) {
        fired++;
        assertEquals("driver", evt.getNewValue());
    } else if (evt.getPropertyName().equals(DatabaseConnection.PROP_DATABASE)) {
        fired++;
        assertEquals("database", evt.getNewValue());
    } else if (evt.getPropertyName().equals(DatabaseConnection.PROP_SCHEMA)) {
        fired++;
        assertEquals("schema", evt.getNewValue());
    } else if (evt.getPropertyName().equals(DatabaseConnection.PROP_USER)) {
        fired++;
        assertEquals("user", evt.getNewValue());
    }
}
 
Example 27
Source Project: dragonwell8_jdk   Source File: SunClipboard.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (AppContext.DISPOSED_PROPERTY_NAME.equals(evt.getPropertyName()) &&
        Boolean.TRUE.equals(evt.getNewValue())) {
        final AppContext disposedContext = (AppContext)evt.getSource();
        lostOwnershipLater(disposedContext);
    }
}
 
Example 28
Source Project: kogito-runtimes   Source File: NamedEntryPoint.java    License: Apache License 2.0 5 votes vote down vote up
public void propertyChange(final PropertyChangeEvent event) {
    final Object object = event.getSource();
    FactHandle handle = getFactHandle( object );
    if ( handle == null ) {
        throw new RuntimeException( "Update error: handle not found for object: " + object + ". Is it in the working memory?" );
    }
    update( handle, object );
}
 
Example 29
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();

    if (prop == JInternalFrame.IS_SELECTED_PROPERTY) {
        repaint();
        return;
    }

    if (prop == JInternalFrame.IS_ICON_PROPERTY ||
            prop == JInternalFrame.IS_MAXIMUM_PROPERTY) {
        setButtonIcons();
        enableActions();
        return;
    }

    if ("closable" == prop) {
        if (evt.getNewValue() == Boolean.TRUE) {
            add(closeButton);
        } else {
            remove(closeButton);
        }
    } else if ("maximizable" == prop) {
        if (evt.getNewValue() == Boolean.TRUE) {
            add(maxButton);
        } else {
            remove(maxButton);
        }
    } else if ("iconable" == prop) {
        if (evt.getNewValue() == Boolean.TRUE) {
            add(iconButton);
        } else {
            remove(iconButton);
        }
    }
    enableActions();

    revalidate();
    repaint();
}
 
Example 30
Source Project: jdk8u60   Source File: MetalInternalFrameUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e)
{
    String name = e.getPropertyName();
    JInternalFrame jif = (JInternalFrame)e.getSource();

    if (!(jif.getUI() instanceof MetalInternalFrameUI)) {
        return;
    }

    MetalInternalFrameUI ui = (MetalInternalFrameUI)jif.getUI();

    if ( name.equals( FRAME_TYPE ) )
    {
        if ( e.getNewValue() instanceof String )
        {
            ui.setFrameType( (String) e.getNewValue() );
        }
    }
    else if ( name.equals(IS_PALETTE_KEY) )
    {
        if ( e.getNewValue() != null )
        {
            ui.setPalette( ((Boolean)e.getNewValue()).booleanValue() );
        }
        else
        {
            ui.setPalette( false );
        }
    } else if ( name.equals( JInternalFrame.CONTENT_PANE_PROPERTY ) ) {
        ui.stripContentBorder(e.getNewValue());
    }
}