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 JComponentActionSetBackground extends AJComponentAction { 46 47 50 private static final long serialVersionUID = 3258131345116181297L; 51 52 53 private Color m_color; 54 55 72 public JComponentActionSetBackground(final JComponent component, final String colorName, final Color color) { 73 super(component, colorName); 74 this.m_color = color; 75 component.addPropertyChangeListener(Chart2D.PROPERTY_BACKGROUND_COLOR, this); 76 } 77 78 81 public void actionPerformed(final ActionEvent e) { 82 this.m_component.setBackground(this.m_color); 83 } 84 85 88 public void propertyChange(final PropertyChangeEvent evt) { 89 String property = evt.getPropertyName(); 90 if (property.equals(Chart2D.PROPERTY_BACKGROUND_COLOR)) { 91 Color newColor = (Color ) evt.getNewValue(); 92 if (newColor.equals(this.m_color)) { 93 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 94 new Boolean (false), new Boolean (true)); 95 96 } else { 97 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 98 new Boolean (true), new Boolean (false)); 99 } 100 } 101 } 102 } 103 | Popular Tags |