Java Code Examples for javax.swing.JComponent#addPropertyChangeListener()

The following examples show how to use javax.swing.JComponent#addPropertyChangeListener() . 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: MigLayoutVisualPadding.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
/**
 * Invokes the given function to retrieve the actual visual paddings and sets
 * the client property. Also adds property change listener to component and
 * re-invokes the function if one of the given properties have changed.
 */
public static void install( JComponent c, Function<JComponent, Insets> getPaddingFunction, String... propertyNames ) {
	if( !migLayoutAvailable )
		return;

	// set client property
	setVisualPadding( c, getPaddingFunction.apply( c ) );

	// add listener
	c.addPropertyChangeListener( (FlatMigListener) e -> {
		String propertyName = e.getPropertyName();
		for( String name : propertyNames ) {
			if( name == propertyName ) {
				setVisualPadding( c, getPaddingFunction.apply( c ) );
				break;
			}
		}
	} );
}
 
Example 2
Source File: PrefPropertyWatcher.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
public synchronized Serializable watch(Object o, Serializable preferences) {
   JComponent component = (JComponent)o;
   
   result = preferences == null ? new PropertyState(property, component) : (PropertyState)preferences;
   
   component.addPropertyChangeListener(property, new PropertyChangeListener() {
PropertyState state = result;

public void propertyChange(PropertyChangeEvent e) {
  System.out.println(e);
  state.grab(e.getNewValue());
}
     });
   
   if(preferences != null)
     result.apply(component);
   
   return result;
 }
 
Example 3
Source File: PaletteUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.addPropertyChangeListener(JPalette.PROPERTY_COLORS,
			propertyLayoutListener);
	c.addPropertyChangeListener(PaletteUI.PROPERTY_HIGHLIGHT,
			propertyRepaintListener);
	c.setLayout(new PaletteLayoutManager());
	c.setRequestFocusEnabled(true);
	c.addMouseListener(mouseListener);
	c.addFocusListener(focusListener);
	c.addKeyListener(keyListener);
	c.setFocusable(true);
	Fields fields = getFields((JPalette) c, true);
	fields.install();
	c.setBorder(new CompoundBorder(new LineBorder(new Color(0xB0B0B0)),
			new FocusedBorder(getDefaultBorder())));
	relayoutCells((JPalette) c);
}
 
Example 4
Source File: FlatToolTipUI.java    From FlatLaf with Apache License 2.0 6 votes vote down vote up
@Override
protected void installListeners( JComponent c ) {
	super.installListeners( c );

	if( sharedPropertyChangedListener == null ) {
		sharedPropertyChangedListener = e -> {
			String name = e.getPropertyName();
			if( name == "text" || name == "font" || name == "foreground" ) {
				JToolTip toolTip = (JToolTip) e.getSource();
				FlatLabelUI.updateHTMLRenderer( toolTip, toolTip.getTipText(), false );
			}
		};
	}

	c.addPropertyChangeListener( sharedPropertyChangedListener );
}
 
Example 5
Source File: AnimatedLayout.java    From pumpernickel with MIT License 5 votes vote down vote up
private void registerChildren(JComponent c) {
	String key = "animatedLayout.propertyListener";
	for (int a = 0; a < c.getComponentCount(); a++) {
		JComponent child = (JComponent) c.getComponent(a);
		if (child.getClientProperty(key) == null) {
			child.putClientProperty(key, destinationListener);
			child.addPropertyChangeListener(PROPERTY_DESTINATION,
					destinationListener);
		}
	}
}
 
Example 6
Source File: QOptionPaneUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.addPropertyChangeListener(optionPanePropertyListener);
	QOptionPane optionPane = (QOptionPane) c;
	installComponents(optionPane);
	updateCustomComponent(optionPane);
	updateIcon(optionPane);
	updateMainMessage(optionPane);
	updateSecondaryMessage(optionPane);
	updateFooter(optionPane);
	updateDialogTitle(optionPane);
}
 
Example 7
Source File: UnicornTreeUI.java    From Data_Processor with Apache License 2.0 5 votes vote down vote up
public void installUI( JComponent c ) {
	super.installUI( c );
	lineColor = UIManager.getColor( "Tree.line" );

	Object lineStyleFlag = c.getClientProperty( LINE_STYLE );
	decodeLineStyle(lineStyleFlag);
	c.addPropertyChangeListener(lineStyleListener);

}
 
Example 8
Source File: MultiThumbSliderUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent slider) {
	slider.addMouseListener(this);
	slider.addMouseMotionListener(this);
	slider.addFocusListener(focusListener);
	slider.addKeyListener(keyListener);
	slider.addComponentListener(compListener);
	slider.addPropertyChangeListener(propertyListener);
	slider.addPropertyChangeListener(THUMB_SHAPE_PROPERTY,
			thumbShapeListener);
	calculateGeometry();
}
 
Example 9
Source File: BasicAudioPlayerUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	getFields(c).install();
	c.addPropertyChangeListener(AudioPlayerComponent.SOURCE_KEY,
			updateSourceListener);
	c.addHierarchyListener(hierarchyListener);
}
 
Example 10
Source File: SubtleScrollBarUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	c.setOpaque(false);
	c.addPropertyChangeListener("opaque", opaqueListener);
	trackColor = new Color(trackColor.getRed(), trackColor.getGreen(),
			trackColor.getBlue(), 0);
	c.addPropertyChangeListener(PROPERTY_ROLLOVER_BOOLEAN, rolloverListener);
	c.addFocusListener(focusListener);
	refreshActive();
	refreshBorder();

}
 
Example 11
Source File: AudioPlayerUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);
	installDefaultSource((AudioPlayerComponent) c);
	c.addPropertyChangeListener(AudioPlayerComponent.PLAYER_KEY,
			audioPlayerListener);
}
 
Example 12
Source File: BreadCrumbUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void installUI(JComponent c) {
	super.installUI(c);

	c.addMouseListener(mouseListener);
	c.addPropertyChangeListener(JBreadCrumb.PATH_KEY, refreshUIListener);
	c.addPropertyChangeListener(JBreadCrumb.FORMATTER_KEY,
			refreshUIListener);
	c.addPropertyChangeListener(PROPERTY_SEPARATOR_ICON, refreshUIListener);
	refreshUI((JBreadCrumb<?>) c);
}
 
Example 13
Source File: ShapeModelerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param parameters
 * @param massDetectorTypeNumber
 */
public ShapeModelerSetupDialog(Window parent, boolean valueCheckRequired,
    ShapeModelerParameters parameters) {

  super(parent, valueCheckRequired, parameters);

  // Parameters of local mass detector to get preview values
  smParameters = parameters;

  // Set a listener in all parameters's fields to add functionality to
  // this dialog
  for (Parameter<?> p : smParameters.getParameters()) {

    if ((p.getName().equals(ShapeModelerParameters.suffix.getName()))
        || (p.getName().equals(ShapeModelerParameters.autoRemove.getName())))
      continue;

    JComponent field = getComponentForParameter(p);
    if (field == null)
      continue;
    field.addPropertyChangeListener("value", this);
    if (field instanceof JCheckBox)
      ((JCheckBox) field).addActionListener(this);
    if (field instanceof JComboBox)
      ((JComboBox<?>) field).addActionListener(this);
  }

  addComponents();

}
 
Example 14
Source File: MultiThumbSliderUI.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void installUI(JComponent slider) {
	slider.addMouseListener(this);
	slider.addMouseMotionListener(this);
	slider.addFocusListener(focusListener);
	slider.addKeyListener(keyListener);
	slider.addComponentListener(compListener);
	slider.addPropertyChangeListener(propertyListener);
	slider.addPropertyChangeListener(THUMB_SHAPE_PROPERTY, thumbShapeListener);
	calculateGeometry();
}
 
Example 15
Source File: AquaOpenLocationPaneUI.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
protected void installGUI(JComponent panel) {
	panel.addPropertyChangeListener(KEY_INCLUDE_SIDEBAR,
			propertyChangeListener);

	if (sourceList.isEmpty()) {
		File[] array1 = CommonFiles.getUserDirectories(true);
		IOLocation[] array2 = new FileLocation[array1.length];
		for (int a = 0; a < array1.length; a++) {
			array2[a] = LocationFactory.get().create(array1[a]);
		}
		sourceList.add(array2);
	}

	boolean includeSidebar = getBoolean(locationPane, KEY_INCLUDE_SIDEBAR,
			true);
	boolean includeFooter = getBoolean(locationPane, KEY_INCLUDE_FOOTER,
			true);

	panel.removeAll();
	panel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.insets = new Insets(4, 0, 4, 0);
	panel.add(controls, c);
	c.gridy++;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;

	if (includeSidebar) {
		splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
				sourceListScrollPane, browser);
		panel.add(splitPane, c);
	} else {
		panel.add(browser, c);
	}

	if (includeFooter) {
		c.weighty = 0;
		c.gridy++;
		panel.add(footer, c);
	}
	sourceListScrollPane.setMinimumSize(new Dimension(100, 40));
	sourceListScrollPane.setPreferredSize(new Dimension(150, 40));
}
 
Example 16
Source File: SeaGlassViewportUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
protected void installListeners(JComponent c) {
    c.addPropertyChangeListener(this);
}
 
Example 17
Source File: SeaGlassToolTipUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
protected void installListeners(JComponent c) {
    c.addPropertyChangeListener(this);
}
 
Example 18
Source File: PToolTipUI.java    From PolyGlot with MIT License 4 votes vote down vote up
protected void installListeners(JComponent c) {
    propertyChangeListener = createPropertyChangeListener(c);

    c.addPropertyChangeListener(propertyChangeListener);
}