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.JColorChooser ; 33 import javax.swing.JComponent ; 34 35 45 public final class JComponentActionSetCustomForeground extends AJComponentAction { 46 47 50 private static final long serialVersionUID = 3904680491952451890L; 51 52 56 private Color m_lastChosenColor; 57 58 72 public JComponentActionSetCustomForeground(final JComponent component, final String description) { 73 super(component, description); 74 component.addPropertyChangeListener(Chart2D.PROPERTY_FOREGROUND_COLOR, this); 75 } 76 77 80 public void actionPerformed(final ActionEvent e) { 81 Color chosen = JColorChooser.showDialog(this.m_component, "choose foreground color for " 82 + this.m_component.getName(), this.m_component.getForeground()); 83 this.m_component.setForeground(chosen); 84 } 85 86 89 public void propertyChange(final PropertyChangeEvent evt) { 90 String property = evt.getPropertyName(); 91 if (property.equals(Chart2D.PROPERTY_FOREGROUND_COLOR)) { 92 Color newColor = (Color ) evt.getNewValue(); 93 if (newColor.equals(this.m_lastChosenColor)) { 94 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 95 new Boolean (false), new Boolean (true)); 96 97 } else { 98 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 99 new Boolean (true), new Boolean (false)); 100 } 101 } 102 } 103 } 104 | Popular Tags |