1 23 package info.monitorenter.gui.chart.events; 24 25 import info.monitorenter.gui.chart.Chart2D; 26 import info.monitorenter.gui.chart.layout.LayoutFactory.PropertyChangeCheckBoxMenuItem; 27 28 import java.awt.Color ; 29 import java.awt.event.ActionEvent ; 30 import java.beans.PropertyChangeEvent ; 31 32 import javax.swing.JComponent ; 33 34 45 public final class JComponentActionSetForeground extends AJComponentAction { 46 47 50 private static final long serialVersionUID = 3258131345116181297L; 51 52 53 private Color m_color; 54 55 73 public JComponentActionSetForeground(final JComponent component, final String colorName, 74 final Color color) { 75 super(component, colorName); 76 this.m_color = color; 77 component.addPropertyChangeListener(Chart2D.PROPERTY_BACKGROUND_COLOR, this); 78 } 79 80 83 public void actionPerformed(final ActionEvent e) { 84 this.m_component.setForeground(this.m_color); 85 } 86 87 90 public void propertyChange(final PropertyChangeEvent evt) { 91 String property = evt.getPropertyName(); 92 if (property.equals(Chart2D.PROPERTY_FOREGROUND_COLOR)) { 93 Color newColor = (Color ) evt.getNewValue(); 94 if (newColor.equals(this.m_color)) { 95 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 96 new Boolean (false), new Boolean (true)); 97 98 } else { 99 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 100 new Boolean (true), new Boolean (false)); 101 } 102 } 103 } 104 } 105 | Popular Tags |