java.beans.PropertyChangeListener Java Examples
The following examples show how to use
java.beans.PropertyChangeListener.
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: Fmrc2Panel.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void showDataset() throws IOException { if (fmrcInv == null) return; if (dialog == null) { dialog = new Fmrc2Dialog(null); dialog.pack(); dialog.addPropertyChangeListener("OK", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { Fmrc2Dialog.Data data = (Fmrc2Dialog.Data) evt.getNewValue(); if ((data.type == null) || (data.where == null)) return; try { processDialog(data); } catch (IOException e) { e.printStackTrace(); } } }); } dialog.setFmrc(fmrc); dialog.setVisible(true); }
Example #2
Source File: BasicLookAndFeel.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
void installAWTEventListener() { if (invocator == null) { invocator = new AWTEventHelper(); needsEventHelper = true; // Add a PropertyChangeListener to our AppContext so we're alerted // when the AppContext is disposed(), at which time this laf should // be uninitialize()d. disposer = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent prpChg) { uninitialize(); } }; AppContext.getAppContext().addPropertyChangeListener( AppContext.GUI_DISPOSED, disposer); } }
Example #3
Source File: bug6994419.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JLayer<JComponent> l = new JLayer<JComponent>(new JButton()); l.removeAll(); l.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { throw new RuntimeException("Property change event was unexpectedly fired"); } }); l.removeAll(); } }); }
Example #4
Source File: HubAlarmDisconnectedPresenter.java From arcusandroid with Apache License 2.0 | 6 votes |
public void addHubPropertyChangeListener() { if (hubModel == null) { logger.debug("Cannot add property change listener to null model."); return; } addListener(hubModel.getClass().getCanonicalName(), hubModel.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(@NonNull PropertyChangeEvent event) { if (event.getPropertyName().equals(HubConnection.ATTR_LASTCHANGE)) { if (isPresenting()) { getPresentedView().setHubLastChangedTime(getHubLastChangedTime()); } } } })); }
Example #5
Source File: BasicLookAndFeel.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
void installAWTEventListener() { if (invocator == null) { invocator = new AWTEventHelper(); needsEventHelper = true; // Add a PropertyChangeListener to our AppContext so we're alerted // when the AppContext is disposed(), at which time this laf should // be uninitialize()d. disposer = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent prpChg) { uninitialize(); } }; AppContext.getAppContext().addPropertyChangeListener( AppContext.GUI_DISPOSED, disposer); } }
Example #6
Source File: BeanContextSupport.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Gets the PropertyChangeListener * (if any) of the specified child * @param child the specified child * @return the PropertyChangeListener (if any) of the specified child */ protected static final PropertyChangeListener getChildPropertyChangeListener(Object child) { try { return (PropertyChangeListener)child; } catch (ClassCastException cce) { return null; } }
Example #7
Source File: DefaultAntBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public Map<String, Object> getReferences() { ObservableMap map = new ObservableMap(getProject().getReferences()); map.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { getProject().addReference(event.getPropertyName(), event.getNewValue()); } }); @SuppressWarnings("unchecked") Map<String, Object> castMap = (Map<String, Object>) map; return castMap; }
Example #8
Source File: Toolkit.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(propertyName, listener); } }
Example #9
Source File: SinglePaneUIInstance.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Component createCenterPanel() { splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitter.setTopComponent(createMainGradlePanel()); splitter.setBottomComponent(outputPanelLord.getMainPanel()); splitter.setContinuousLayout(true); //This little bit of tedium is so we can set our size based on window's size. This listens //for when the window is actually shown. It then adds a listen to store the location. splitter.addHierarchyListener(new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { if (HierarchyEvent.SHOWING_CHANGED == (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED)) { splitter.removeHierarchyListener(this); //we only want the first one of these, so remove ourselves as a listener. Window window = SwingUtilities.getWindowAncestor(splitter); if (window != null) { Dimension dimension = window.getSize(); int halfHeight = dimension.height / 2; //we'll just make ourselves half the height of the window splitter.setDividerLocation(halfHeight); } PreferencesAssistant.restoreSettings(settings, splitter, SPLITTER_PREFERENCES_ID, SinglePaneUIInstance.class); //Now that we're visible, this is so we save the location when the splitter is moved. splitter.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JSplitPane.DIVIDER_LOCATION_PROPERTY.equals(evt.getPropertyName())) { PreferencesAssistant.saveSettings(settings, splitter, SPLITTER_PREFERENCES_ID, SinglePaneUIInstance.class); } } }); } } }); splitter.setResizeWeight(1); //this keeps the bottom the same size when resizing the window. Extra space is added/removed from the top. return splitter; }
Example #10
Source File: Toolkit.java From JDKSourceCode1.8 with MIT License | 5 votes |
@Override public synchronized PropertyChangeListener[] getPropertyChangeListeners() { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { return pcs.getPropertyChangeListeners(); } else { return new PropertyChangeListener[0]; } }
Example #11
Source File: TestSerialization.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void check(PropertyChangeListener listener, int index) { if (!(listener instanceof TestSerialization)) throw new Error("Unexpected listener: " + listener); TestSerialization object = (TestSerialization)listener; if (index != object.index) throw new Error("Unexpected index: " + index + " != " + object.index); }
Example #12
Source File: JInternalFrame.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void addPropertyChangeListenerIfNecessary() { if (AppContext.getAppContext().get(PROPERTY_CHANGE_LISTENER_KEY) == null) { PropertyChangeListener focusListener = new FocusPropertyChangeListener(); AppContext.getAppContext().put(PROPERTY_CHANGE_LISTENER_KEY, focusListener); KeyboardFocusManager.getCurrentKeyboardFocusManager(). addPropertyChangeListener(focusListener); } }
Example #13
Source File: Context.java From JsDroidCmd with Mozilla Public License 2.0 | 5 votes |
private void firePropertyChangeImpl(Object listeners, String property, Object oldValue, Object newValue) { for (int i = 0; ; ++i) { Object l = Kit.getListener(listeners, i); if (l == null) break; if (l instanceof PropertyChangeListener) { PropertyChangeListener pcl = (PropertyChangeListener)l; pcl.propertyChange(new PropertyChangeEvent( this, property, oldValue, newValue)); } } }
Example #14
Source File: RowHeaderList.java From CXTouch with GNU General Public License v3.0 | 5 votes |
/** * Create a new row header list. */ JList getRowHeadList() { int tableRowCount = getModel().getSize(); final PrivateList rowHeader = new PrivateList(tableRowCount); rowHeader.setFixedCellHeight(getFixedCellHeight()); RowHeaderRenderer cellRender = new RowHeaderRenderer(this); rowHeader.setCellRenderer(cellRender); int width = 10; if (tableRowCount > 0) { width = (int) cellRender.getListCellRendererComponent(rowHeader, null, tableRowCount - 1, false, false) .getPreferredSize().getWidth() + 16; } rowHeader.setFixedCellWidth(width); addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("fixedCellHeight")) { rowHeader.setFixedCellHeight(getFixedCellHeight()); } } } ); return rowHeader; }
Example #15
Source File: BasicTabbedPaneUI.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
protected PropertyChangeListener createPropertyChangeListener() { return getHandler(); }
Example #16
Source File: Test4353056.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void removePropertyChangeListener(PropertyChangeListener listener) { this.pcs.removePropertyChangeListener(listener); }
Example #17
Source File: CopyDataToExcelFile.java From constellation with Apache License 2.0 | 4 votes |
@Override public void removePropertyChangeListener(final PropertyChangeListener listener) { // Required for implementation of Action, intentionally left blank }
Example #18
Source File: FailedContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Override public void removePropertyChangeListener(PropertyChangeListener listener) { /* NO-OP */ }
Example #19
Source File: TestListeners.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { PropertyChangeSupport pcs = new PropertyChangeSupport(TestListeners.class); pcs.addPropertyChangeListener(new TestListeners(0)); pcs.addPropertyChangeListener(NAME, new TestListeners(2)); pcs.addPropertyChangeListener(new TestListeners(1)); pcs.addPropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3))); current = 0; pcs.firePropertyChange(NAME, 0, 1); if (current != 4) throw new Error("Expected 4 listeners, but called " + current); current = 0; pcs.firePropertyChange(NONE, 1, 0); if (current != 2) throw new Error("Expected 2 listeners, but called " + current); PropertyChangeListener[] all = pcs.getPropertyChangeListeners(); if (all.length != 4) throw new Error("Expected 4 listeners, but contained " + all.length); PropertyChangeListener[] named = pcs.getPropertyChangeListeners(NAME); if (named.length != 2) throw new Error("Expected 2 named listeners, but contained " + named.length); PropertyChangeListener[] other = pcs.getPropertyChangeListeners(NONE); if (other.length != 0) throw new Error("Expected 0 other listeners, but contained " + other.length); pcs.removePropertyChangeListener(new TestListeners(0)); pcs.removePropertyChangeListener(new TestListeners(1)); pcs.removePropertyChangeListener(NAME, new TestListeners(2)); pcs.removePropertyChangeListener(NAME, new PropertyChangeListenerProxy(NAME, new TestListeners(3))); all = pcs.getPropertyChangeListeners(); if (all.length != 0) throw new Error("Expected 4 listeners, but contained " + all.length); named = pcs.getPropertyChangeListeners(NAME); if (named.length != 0) throw new Error("Expected 2 named listeners, but contained " + named.length); other = pcs.getPropertyChangeListeners(NONE); if (other.length != 0) throw new Error("Expected 0 other listeners, but contained " + other.length); }
Example #20
Source File: OptionsPanel.java From ghidra with Apache License 2.0 | 4 votes |
public OptionsPanel(String rootName, Options[] options, boolean showRestoreDefaultsButton, PropertyChangeListener changeListener) { this.changeListener = changeListener; updateManager = new SwingUpdateManager(100, () -> { OptionsTreeNode node = null; TreePath selectedPath = gTree.getSelectionPath(); if (selectedPath != null) { node = (OptionsTreeNode) selectedPath.getLastPathComponent(); } if (node == null) { return; // this can happen while the tree is loading and being filtered } processSelection(node); }); setLayout(new BorderLayout()); // assume that one options implies it's a root if (options.length == 1) { rootNode = new OptionsRootTreeNode(options[0]); } // else, create a dummy root with the given name else { rootNode = new OptionsRootTreeNode(rootName, options); } gTree = new GTree(rootNode); gTree.addGTreeSelectionListener(e -> updateManager.updateLater()); gTree.setDataTransformer(new OptionsDataTransformer()); viewPanel = new JPanel(new BorderLayout()); viewPanel.setName("View"); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, gTree, viewPanel); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); Dimension minSize = new Dimension(100, 300); gTree.setMinimumSize(minSize); viewPanel.setMinimumSize(minSize); splitPane.setBorder(null); add(splitPane, BorderLayout.CENTER); gTree.expandPath(new TreePath(new Object[] { rootNode })); TreeSelectionModel selModel = gTree.getSelectionModel(); selModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); defaultPanel = createDefaultPanel(); viewPanel.add(defaultPanel, BorderLayout.CENTER); gTree.setSelectedNode(rootNode); optionsEditorContainer = new JPanel(new BorderLayout()); // put the component on the lower-right of the overall options pane restoreDefaultPanel = new JPanel(); restoreDefaultPanel.setLayout(new BorderLayout()); if (showRestoreDefaultsButton) { restoreDefaultPanel.add(createRestoreDefaultsButton(), BorderLayout.EAST); } }
Example #21
Source File: WindowsInternalFrameTitlePane.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
protected PropertyChangeListener createPropertyChangeListener() { return new WindowsPropertyChangeHandler(); }
Example #22
Source File: JLightweightFrame.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Constructs a new, initially invisible {@code JLightweightFrame} * instance. */ public JLightweightFrame() { super(); copyBufferEnabled = "true".equals(AccessController. doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); add(rootPane, BorderLayout.CENTER); setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); if (getGraphicsConfiguration().isTranslucencyCapable()) { setBackground(new Color(0, 0, 0, 0)); } layoutSizeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { Dimension d = (Dimension)e.getNewValue(); if ("preferredSize".equals(e.getPropertyName())) { content.preferredSizeChanged(d.width, d.height); } else if ("maximumSize".equals(e.getPropertyName())) { content.maximumSizeChanged(d.width, d.height); } else if ("minimumSize".equals(e.getPropertyName())) { content.minimumSizeChanged(d.width, d.height); } } }; repaintListener = (JComponent c, int x, int y, int w, int h) -> { Window jlf = SwingUtilities.getWindowAncestor(c); if (jlf != JLightweightFrame.this) { return; } Point p = SwingUtilities.convertPoint(c, x, y, jlf); Rectangle r = new Rectangle(p.x, p.y, w, h).intersection( new Rectangle(0, 0, bbImage.getWidth() / scaleFactor, bbImage.getHeight() / scaleFactor)); if (!r.isEmpty()) { notifyImageUpdated(r.x, r.y, r.width, r.height); } }; SwingAccessor.getRepaintManagerAccessor().addRepaintListener( RepaintManager.currentManager(this), repaintListener); }
Example #23
Source File: UIAction.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void addPropertyChangeListener(PropertyChangeListener listener) { }
Example #24
Source File: Test6194788.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public void addPropertyChangeListener(PropertyChangeListener listener) { }
Example #25
Source File: BasicTabbedPaneUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
protected PropertyChangeListener createPropertyChangeListener() { return getHandler(); }
Example #26
Source File: AbstractButton.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
PropertyChangeListener createActionPropertyChangeListener0(Action a) { return new ButtonActionPropertyChangeListener(this, a); }
Example #27
Source File: MetalInternalFrameTitlePane.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
protected PropertyChangeListener createPropertyChangeListener() { return new MetalPropertyChangeHandler(); }
Example #28
Source File: ImageFileChooser.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
/** * Constructor */ public ImageFileChooser() { super(); dpiCB = new JComboBox(); DefaultComboBoxModel cbm = new DefaultComboBoxModel(); cbm.addElement("Default"); cbm.addElement("150"); cbm.addElement("300"); cbm.addElement("600"); cbm.addElement("900"); cbm.addElement("1200"); dpiCB.setModel(cbm); dpiCB.setEditable(true); panel = new JPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(5, 10, 0, 0); constraints.gridx = 0; constraints.gridy = 0; panel.add(new JLabel("DPI:"), constraints); constraints.gridy = 1; panel.add(dpiCB, constraints); setAccessory(panel); //panel.setVisible(false); this.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { String prop = pce.getPropertyName(); //If a file became selected, find out which one. if (JFileChooser.FILE_FILTER_CHANGED_PROPERTY.equals(prop)) { GenericFileFilter filter = (GenericFileFilter) pce.getNewValue(); if (filter != null){ switch (filter.getFileExtent().toLowerCase()) { case "png": case "jpg": case "bmp": case "gif": panel.setVisible(true); break; default: panel.setVisible(false); break; } repaint(); } } } }); }
Example #29
Source File: WindowsTitlePane.java From darklaf with MIT License | 4 votes |
private PropertyChangeListener createWindowPropertyChangeListener() { return new PropertyChangeHandler(); }
Example #30
Source File: BasicOptionPaneUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
protected PropertyChangeListener createPropertyChangeListener() { return getHandler(); }