下面列出了javax.swing.JComponent#addPropertyChangeListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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 );
}
/**
* 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;
}
}
} );
}
@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);
}
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;
}
public void installUI( JComponent c ) {
super.installUI( c );
lineColor = UIManager.getColor( "Tree.line" );
Object lineStyleFlag = c.getClientProperty( LINE_STYLE );
decodeLineStyle(lineStyleFlag);
c.addPropertyChangeListener(lineStyleListener);
}
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);
}
}
}
@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);
}
@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();
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
getFields(c).install();
c.addPropertyChangeListener(AudioPlayerComponent.SOURCE_KEY,
updateSourceListener);
c.addHierarchyListener(hierarchyListener);
}
@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();
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
installDefaultSource((AudioPlayerComponent) c);
c.addPropertyChangeListener(AudioPlayerComponent.PLAYER_KEY,
audioPlayerListener);
}
@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);
}
/**
* @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();
}
@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();
}
@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));
}
protected void installListeners(JComponent c) {
c.addPropertyChangeListener(this);
}
/**
* @inheritDoc
*/
@Override
protected void installListeners(JComponent c) {
c.addPropertyChangeListener(this);
}
protected void installListeners(JComponent c) {
propertyChangeListener = createPropertyChangeListener(c);
c.addPropertyChangeListener(propertyChangeListener);
}