jtulach@0: /* jtulach@0: * Sun Public License Notice jtulach@0: * jtulach@0: * The contents of this file are subject to the Sun Public License jtulach@0: * Version 1.0 (the "License"). You may not use this file except in jtulach@0: * compliance with the License. A copy of the License is available at jtulach@0: * http://www.sun.com/ jtulach@0: * jtulach@0: * The Original Code is NetBeans. The Initial Developer of the Original jtulach@0: * Code is Sun Microsystems, Inc. Portions Copyright 1999-2006 Sun jtulach@0: * Microsystems, Inc. All Rights Reserved. jtulach@0: */ jtulach@0: jtulach@0: package apipkg; jtulach@0: jtulach@0: import implpkg.Accessor; jtulach@0: import javax.swing.event.ChangeEvent; jtulach@0: import javax.swing.event.ChangeListener; jtulach@0: jtulach@0: /** Class in API that everyone can use. jtulach@0: * jtulach@0: * @author Jaroslav Tulach jtulach@0: */ jtulach@3: // BEGIN: design.less.friend.Item jtulach@0: public final class Item { jtulach@0: private int value; jtulach@0: private ChangeListener listener; jtulach@3: jtulach@3: // BEGIN: design.less.friend.Item.static jtulach@0: static { jtulach@0: Accessor.DEFAULT = new AccessorImpl(); jtulach@0: } jtulach@3: // END: design.less.friend.Item.static jtulach@0: jtulach@0: /** Contructor for friends */ jtulach@0: Item() { jtulach@0: } jtulach@0: jtulach@0: /** Anyone can value of the item. At least if it can get a reference to it. jtulach@0: */ jtulach@0: public void setValue(int x) { jtulach@0: value = x; jtulach@0: ChangeListener l = listener; jtulach@0: if (l != null) { jtulach@0: l.stateChanged(new ChangeEvent(this)); jtulach@0: } jtulach@0: } jtulach@0: jtulach@0: /** Anyone can get the value of the item. jtulach@0: */ jtulach@0: public int getValue() { jtulach@0: return value; jtulach@0: } jtulach@0: jtulach@0: /** Only the impl package can listen. jtulach@0: */ jtulach@0: void addChangeListener(ChangeListener l) { jtulach@0: assert listener == null; jtulach@0: listener = l; jtulach@0: } jtulach@0: jtulach@0: } jtulach@3: // END: design.less.friend.Item