1 29 30 package nextapp.echo2.app.button; 31 32 import java.util.EventListener ; 33 34 import nextapp.echo2.app.event.ChangeEvent; 35 import nextapp.echo2.app.event.ChangeListener; 36 37 40 public class DefaultToggleButtonModel extends DefaultButtonModel 41 implements ToggleButtonModel { 42 43 private boolean selected; 44 45 48 public void addChangeListener(ChangeListener l) { 49 getEventListenerList().addListener(ChangeListener.class, l); 50 } 51 52 55 public void fireStateChanged() { 56 EventListener [] listeners = getEventListenerList().getListeners(ChangeListener.class); 57 ChangeEvent e = new ChangeEvent(this); 58 for (int index = 0; index < listeners.length; ++index) { 59 ((ChangeListener) listeners[index]).stateChanged(e); 60 } 61 } 62 63 66 public boolean isSelected() { 67 return selected; 68 } 69 70 73 public void removeChangeListener(ChangeListener l) { 74 getEventListenerList().removeListener(ChangeListener.class, l); 75 } 76 77 80 public void setSelected(boolean selected) { 81 this.selected = selected; 82 fireStateChanged(); 83 } 84 } 85 | Popular Tags |