| 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 34 44 public final class Chart2DActionSetCustomGridColor extends AChart2DAction { 45 48 private static final long serialVersionUID = 3691034370412916788L; 49 50 54 private Color m_lastChosenColor; 55 56 69 public Chart2DActionSetCustomGridColor(final Chart2D chart, final String colorName) { 70 super(chart, colorName); 71 chart.addPropertyChangeListener(Chart2D.PROPERTY_GRID_COLOR, this); 72 } 73 74 77 public void actionPerformed(final ActionEvent e) { 78 Color chosen = JColorChooser.showDialog(this.m_chart, "choose color for " 79 + this.m_chart.getName(), this.m_chart.getGridColor()); 80 this.m_lastChosenColor = chosen; 81 this.m_chart.setGridColor(chosen); 82 } 83 84 87 public void propertyChange(final PropertyChangeEvent evt) { 88 String property = evt.getPropertyName(); 89 if (property.equals(Chart2D.PROPERTY_GRID_COLOR)) { 90 Color newColor = (Color ) evt.getNewValue(); 91 if (newColor.equals(this.m_lastChosenColor)) { 92 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 93 new Boolean (false), new Boolean (true)); 94 95 } else { 96 this.firePropertyChange(PropertyChangeCheckBoxMenuItem.PROPERTY_SELECTED, 97 new Boolean (true), new Boolean (false)); 98 } 99 } 100 } 101 } 102 | Popular Tags |