java.beans.PropertyChangeEvent#getSource ( )源码实例Demo

下面列出了java.beans.PropertyChangeEvent#getSource ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-jdk   文件: MotifInternalFrameTitlePane.java
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();
}
 
源代码2 项目: jdk8u60   文件: NimbusLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * <p>Overridden to return {@code true} when one of the following
 * properties change:
 * <ul>
 *   <li>{@code "Nimbus.Overrides"}
 *   <li>{@code "Nimbus.Overrides.InheritDefaults"}
 *   <li>{@code "JComponent.sizeVariant"}
 * </ul>
 *
 * @since 1.7
 */
@Override
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
    String eName = ev.getPropertyName();

    // These properties affect style cached inside NimbusDefaults (6860433)
    if ("name" == eName ||
        "ancestor" == eName ||
        "Nimbus.Overrides" == eName ||
        "Nimbus.Overrides.InheritDefaults" == eName ||
        "JComponent.sizeVariant" == eName) {

        JComponent c = (JComponent) ev.getSource();
        defaults.clearOverridesCache(c);
        return true;
    }

    return super.shouldUpdateStyleOnEvent(ev);
}
 
源代码3 项目: openjdk-8-source   文件: NimbusLookAndFeel.java
/**
 * {@inheritDoc}
 *
 * <p>Overridden to return {@code true} when one of the following
 * properties change:
 * <ul>
 *   <li>{@code "Nimbus.Overrides"}
 *   <li>{@code "Nimbus.Overrides.InheritDefaults"}
 *   <li>{@code "JComponent.sizeVariant"}
 * </ul>
 *
 * @since 1.7
 */
@Override
protected boolean shouldUpdateStyleOnEvent(PropertyChangeEvent ev) {
    String eName = ev.getPropertyName();

    // These properties affect style cached inside NimbusDefaults (6860433)
    if ("name" == eName ||
        "ancestor" == eName ||
        "Nimbus.Overrides" == eName ||
        "Nimbus.Overrides.InheritDefaults" == eName ||
        "JComponent.sizeVariant" == eName) {

        JComponent c = (JComponent) ev.getSource();
        defaults.clearOverridesCache(c);
        return true;
    }

    return super.shouldUpdateStyleOnEvent(ev);
}
 
源代码4 项目: tomcatsrc   文件: NamingContextListener.java
/**
 * Process property change events.
 *
 * @param event The property change event that has occurred
 */
@Override
public void propertyChange(PropertyChangeEvent event) {

    if (!initialized)
        return;

    Object source = event.getSource();
    if (source == namingResources) {

        // Setting the context in read/write mode
        ContextAccessController.setWritable(getName(), container);

        processGlobalResourcesChange(event.getPropertyName(),
                                     event.getOldValue(),
                                     event.getNewValue());

        // Setting the context in read only mode
        ContextAccessController.setReadOnly(getName());

    }

}
 
源代码5 项目: dragonwell8_jdk   文件: ElementTreePanel.java
/**
 * 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);
    }
}
 
源代码6 项目: gcs   文件: FeatureEditor.java
@Override
public void propertyChange(PropertyChangeEvent event) {
    if ("value".equals(event.getPropertyName())) {
        EditorField   field = (EditorField) event.getSource();
        LeveledAmount amt   = (LeveledAmount) field.getClientProperty(LeveledAmount.class);
        if (amt != null) {
            if (amt.isIntegerOnly()) {
                amt.setAmount(((Integer) field.getValue()).intValue());
            } else {
                amt.setAmount(((Double) field.getValue()).doubleValue());
            }
            notifyActionListeners();
        } else {
            super.propertyChange(event);
        }
    } else {
        super.propertyChange(event);
    }
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: BasicMenuItemUI.java
public void propertyChange(PropertyChangeEvent e) {
    String name = e.getPropertyName();

    if (name == "labelFor" || name == "displayedMnemonic" ||
        name == "accelerator") {
        updateAcceleratorBinding();
    } else if (name == "text" || "font" == name ||
               "foreground" == name) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JMenuItem lbl = ((JMenuItem) e.getSource());
        String text = lbl.getText();
        BasicHTML.updateRenderer(lbl, text);
    } else if (name  == "iconTextGap") {
        defaultTextIconGap = ((Number)e.getNewValue()).intValue();
    } else if (name == "horizontalTextPosition") {
        updateCheckIcon();
    }
}
 
源代码8 项目: jdk8u_jdk   文件: SynthInternalFrameTitlePane.java
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getSource() == this) {
        if (SynthLookAndFeel.shouldUpdateStyle(evt)) {
            updateStyle(this);
        }
    }
    else {
        // Changes for the internal frame
        if (evt.getPropertyName() == JInternalFrame.FRAME_ICON_PROPERTY) {
            updateMenuIcon();
        }
    }
}
 
源代码9 项目: openjdk-8   文件: StyledEditorKit.java
public void propertyChange(PropertyChangeEvent evt) {
    Object newValue = evt.getNewValue();
    Object source = evt.getSource();

    if ((source instanceof JTextComponent) &&
        (newValue instanceof Document)) {
        // New document will have changed selection to 0,0.
        updateInputAttributes(0, 0, (JTextComponent)source);
    }
}
 
源代码10 项目: netbeans   文件: StartManager.java
@Override
public void propertyChange(PropertyChangeEvent evt) {
    final DatabaseServer server = (DatabaseServer)evt.getSource();
    if ((MySQLOptions.PROP_START_ARGS.equals(evt.getPropertyName()) ||
            MySQLOptions.PROP_START_PATH.equals(evt.getPropertyName())) && (startRequested.get())) {
        start(server);
    }
}
 
源代码11 项目: openjdk-8-source   文件: BasicScrollPaneUI.java
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == scrollpane) {
        scrollPanePropertyChange(e);
    }
    else {
        sbPropertyChange(e);
    }
}
 
源代码12 项目: netbeans   文件: TruffleAccess.java
@Override
public void propertyChange(PropertyChangeEvent evt) {
    JPDAThreadImpl t = (JPDAThreadImpl) evt.getSource();
    if (!(Boolean) evt.getNewValue() && !t.isMethodInvoking()) { // not suspended, resumed
        synchronized (currentPCInfos) {
            ThreadInfo info = currentPCInfos.get(t);
            if (info != null) {
                info.cpi = null;
            }
        }
    }
}
 
源代码13 项目: jdk1.8-source-analysis   文件: BasicScrollPaneUI.java
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == scrollpane) {
        scrollPanePropertyChange(e);
    }
    else {
        sbPropertyChange(e);
    }
}
 
源代码14 项目: netbeans   文件: Schema2BeansUtil.java
public void propertyChange(PropertyChangeEvent evt) {
    Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();
    if (oldValue == null && newValue != null) {
        String path = evt.getPropertyName();
        BaseBean bean = (BaseBean) evt.getSource();
        Node node = findNode(bean, path);
        if (node != null) {
            reindentNode(node);
        }
    }
}
 
源代码15 项目: AliceBot   文件: ContextRandomSeedChangeListener.java
public void propertyChange(PropertyChangeEvent event)
{
  Context context = (Context) event.getSource();
  Object oldSeed = event.getOldValue();
  Object newSeed = event.getNewValue();
  
  if (oldSeed == null ? newSeed == null : oldSeed.equals(newSeed))
    return;
  
  long seed = Long.parseLong(newSeed.toString());
  context.random(seed);
}
 
源代码16 项目: darklaf   文件: DarkToolTipUI.java
@Override
public void propertyChange(final PropertyChangeEvent evt) {
    String key = evt.getPropertyName();
    if (evt.getSource() instanceof JToolTip) {
        JToolTip tooltip = (JToolTip) evt.getSource();
        if (tooltip.getBorder() instanceof AlignableTooltipBorder) {
            AlignableTooltipBorder b = (AlignableTooltipBorder) tooltip.getBorder();
            Object newVal = evt.getNewValue();
            if (KEY_POINTER_LOCATION.equals(key)) {
                if (newVal instanceof Alignment) {
                    b.setPointerLocation((Alignment) newVal, pointerEnabled());
                } else {
                    b.setPointerLocation(Alignment.CENTER, pointerEnabled());
                }
                updateSize();
            }

            if (b instanceof DarkTooltipBorder) {
                DarkTooltipBorder border = (DarkTooltipBorder) tooltip.getBorder();
                if (pointerEnabled() && KEY_POINTER_HEIGHT.equals(key)) {
                    if (newVal instanceof Integer) {
                        border.setPointerHeight((Integer) newVal);
                    }
                    updateSize();
                } else if (pointerEnabled() && KEY_POINTER_WIDTH.equals(key)) {
                    if (newVal instanceof Integer) {
                        border.setPointerWidth((Integer) newVal);
                    }
                    updateSize();
                } else if (KEY_INSETS.equals(key)) {
                    updateSize();
                }
            }
        }
        if (PropertyKey.COMPONENT.equals(key)) {
            Object oldComp = evt.getOldValue();
            if (oldComp instanceof Component) {
                ((Component) oldComp).removeMouseListener(mouseListener);
                ((Component) oldComp).removePropertyChangeListener(componentPropertyChaneListener);
            }
            Object newComp = evt.getNewValue();
            if (newComp instanceof Component) {
                ((Component) newComp).addMouseListener(mouseListener);
                ((Component) newComp).addPropertyChangeListener(componentPropertyChaneListener);
            }
            updateStyle();
        } else if (TIP_TEXT_PROPERTY.equals(key)) {
            updateTipText(tooltip);
            updateSize();
        } else if (PropertyKey.ANCESTOR.equals(key)) {
            if (evt.getOldValue() == null) {
                // Added to hierarchy. Schedule animation start.
                scheduleAnimation();
                ToolTipUtil.applyContext(toolTip);
            }
            if (evt.getNewValue() == null) {
                alpha = 0;
            }
        }
    }
}
 
源代码17 项目: darklaf   文件: CustomDialog.java
/**
 * This method reacts to state changes in the option pane.
 */
public void propertyChange(final PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop) ||
            JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
        Object value = optionPane.getValue();

        if (value == JOptionPane.UNINITIALIZED_VALUE) {
            // ignore reset
            return;
        }

        // Reset the JOptionPane's value.
        // If you don't do this, then if the user
        // presses the same button next time, no
        // property change event will be fired.
        optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

        if (btnString1.equals(value)) {
            typedText = textField.getText();
            String ucText = typedText.toUpperCase();
            if (magicWord.equals(ucText)) {
                // we're done; clear and dismiss the dialog
                clearAndHide();
            } else {
                // text was invalid
                textField.selectAll();
                JOptionPane.showMessageDialog(CustomDialog.this,
                                              "Sorry, \"" + typedText + "\" " + "isn't a valid response.\n"
                                                                 + "Please enter " + magicWord + ".",
                                              "Try again", JOptionPane.ERROR_MESSAGE);
                typedText = null;
                textField.requestFocusInWindow();
            }
        } else { // user closed dialog or clicked cancel
            dd.setLabel("It's OK.   We won't force you to type " + magicWord + ".");
            typedText = null;
            clearAndHide();
        }
    }
}
 
源代码18 项目: netbeans   文件: EditorCaret.java
public @Override void propertyChange(PropertyChangeEvent evt) {
            String propName = evt.getPropertyName();
            JTextComponent c = component;
            if ("document".equals(propName)) { // NOI18N
                if (c != null) {
                    modelChanged(activeDoc, c.getDocument());
                }

            } else if (EditorUtilities.CARET_OVERWRITE_MODE_PROPERTY.equals(propName)) {
                Boolean b = (Boolean) evt.getNewValue();
                overwriteMode = (b != null) ? b : false;
                updateOverwriteModeLayer(true);
                updateType();

            } else if ("ancestor".equals(propName) && evt.getSource() == component) { // NOI18N
                // The following code ensures that when the width of the line views
                // gets computed on background after the file gets opened
                // (so the horizontal scrollbar gets added after several seconds
                // for larger files) that the suddenly added horizontal scrollbar
                // will not hide the caret laying on the last line of the viewport.
                // A component listener gets installed into horizontal scrollbar
                // and if it's fired the caret's bounds will be checked whether
                // they intersect with the horizontal scrollbar
                // and if so the view will be scrolled.
                final JViewport viewport = getViewport();
                if (viewport != null) {
                    Component parent = viewport.getParent();
                    if (parent instanceof JScrollPane) {
                        JScrollPane scrollPane = (JScrollPane) parent;
                        JScrollBar hScrollBar = scrollPane.getHorizontalScrollBar();
                        if (hScrollBar != null) {
                            // Add weak listener so that editor pane could be removed
                            // from scrollpane without being held by scrollbar
                            hScrollBar.addComponentListener(
                                    (ComponentListener) WeakListeners.create(
                                            ComponentListener.class, listenerImpl, hScrollBar));
                        }
                    }
                }
            } else if ("enabled".equals(propName)) {
                Boolean enabled = (Boolean) evt.getNewValue();
                if (component.isFocusOwner()) {
                    if (enabled == Boolean.TRUE) {
                        if (component.isEditable()) {
                            setVisible(true);
                        }
                        setSelectionVisible(true);
                    } else {
                        setVisible(false);
                        setSelectionVisible(false);
                    }
                }
            } else if (RECTANGULAR_SELECTION_PROPERTY.equals(propName)) {
                boolean origRectangularSelection = rectangularSelection;
                rectangularSelection = Boolean.TRUE.equals(component.getClientProperty(RECTANGULAR_SELECTION_PROPERTY));
                if (rectangularSelection != origRectangularSelection) {
                    if (rectangularSelection) {
                        setRectangularSelectionToDotAndMark();
//                        RectangularSelectionTransferHandler.install(component);

                    } else { // No rectangular selection
//                        RectangularSelectionTransferHandler.uninstall(component);
                    }
                    fireStateChanged(null);
                }
            }
        }
 
源代码19 项目: netbeans   文件: SummaryView.java
@Override
public void propertyChange (PropertyChangeEvent evt) {
    if (RepositoryRevision.PROP_EVENTS_CHANGED.equals(evt.getPropertyName()) && revision == evt.getSource()) {
        refreshEvents();
    }
}
 
源代码20 项目: openjdk-8-source   文件: bug6800513.java
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (evt.toString().contains("visible") && ((Boolean) evt.getNewValue() == true)) {
        popupMenu = (JPopupMenu) evt.getSource();
    }
}