15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.event; 27 28 import java.awt.AWTEvent; 29 import java.awt.ItemSelectable; 30 31 /** 32 * A semantic event which indicates that an item was selected or deselected. 33 * This high-level event is generated by an ItemSelectable object (such as a 34 * List) when an item is selected or deselected by the user. 35 * The event is passed to every <code>ItemListener</code> object which 36 * registered to receive such events using the component's 37 * <code>addItemListener</code> method. 38 * <P> 39 * The object that implements the <code>ItemListener</code> interface gets 40 * this <code>ItemEvent</code> when the event occurs. The listener is 41 * spared the details of processing individual mouse movements and mouse 42 * clicks, and can instead process a "meaningful" (semantic) event like 43 * "item selected" or "item deselected". 44 * <p> 45 * An unspecified behavior will be caused if the {@code id} parameter 46 * of any particular {@code ItemEvent} instance is not 47 * in the range from {@code ITEM_FIRST} to {@code ITEM_LAST}. 48 * <p> 49 * The {@code stateChange} of any {@code ItemEvent} instance takes one of the following 50 * values: 51 * <ul> 52 * <li> {@code ItemEvent.SELECTED} 53 * <li> {@code ItemEvent.DESELECTED} 54 * </ul> 55 * Assigning the value different from listed above will cause an unspecified behavior. 56 * 57 * @author Carl Quinn 58 * 59 * @see java.awt.ItemSelectable 60 * @see ItemListener 81 82 /** 83 * This state-change value indicates that an item was selected. 84 */ 85 public static final int SELECTED = 1; 86 87 /** 88 * This state-change-value indicates that a selected item was deselected. 89 */ 90 public static final int DESELECTED = 2; 91 92 /** 93 * The item whose selection state has changed. 94 * 95 * @serial 96 * @see #getItem() 97 */ 98 Object item; 99 100 /** 101 * <code>stateChange</code> indicates whether the <code>item</code> 102 * was selected or deselected. 103 * 104 * @serial 105 * @see #getStateChange() 106 */ 107 int stateChange; 108 109 /* 110 * JDK 1.1 serialVersionUID 111 */ 112 private static final long serialVersionUID = -608708132447206933L; 113 114 /** 115 * Constructs an <code>ItemEvent</code> object. 116 * <p> This method throws an 117 * <code>IllegalArgumentException</code> if <code>source</code> 118 * is <code>null</code>. 119 * 120 * @param source The <code>ItemSelectable</code> object 121 * that originated the event 122 * @param id The integer that identifies the event type. 123 * For information on allowable values, see 124 * the class description for {@link ItemEvent} 125 * @param item An object -- the item affected by the event 126 * @param stateChange An integer that indicates whether the item was 127 * selected or deselected. 128 * For information on allowable values, see 129 * the class description for {@link ItemEvent} 130 * @throws IllegalArgumentException if <code>source</code> is null 131 * @see #getItemSelectable() 132 * @see #getID() 133 * @see #getStateChange() 134 */ 135 public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) { 136 super(source, id); 137 this.item = item; 138 this.stateChange = stateChange; 139 } 140 141 /** 142 * Returns the originator of the event. 143 * 144 * @return the ItemSelectable object that originated the event. 145 */ 146 public ItemSelectable getItemSelectable() { 147 return (ItemSelectable)source; 148 } 149 150 /** | 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.event; 27 28 import java.awt.AWTEvent; 29 import java.awt.ItemSelectable; 30 31 /** 32 * A semantic event which indicates that an item was selected or deselected. 33 * This high-level event is generated by an ItemSelectable object (such as a 34 * List) when an item is selected or deselected by the user. 35 * The event is passed to every {@code ItemListener} object which 36 * registered to receive such events using the component's 37 * {@code addItemListener} method. 38 * <P> 39 * The object that implements the {@code ItemListener} interface gets 40 * this {@code ItemEvent} when the event occurs. The listener is 41 * spared the details of processing individual mouse movements and mouse 42 * clicks, and can instead process a "meaningful" (semantic) event like 43 * "item selected" or "item deselected". 44 * <p> 45 * An unspecified behavior will be caused if the {@code id} parameter 46 * of any particular {@code ItemEvent} instance is not 47 * in the range from {@code ITEM_FIRST} to {@code ITEM_LAST}. 48 * <p> 49 * The {@code stateChange} of any {@code ItemEvent} instance takes one of the following 50 * values: 51 * <ul> 52 * <li> {@code ItemEvent.SELECTED} 53 * <li> {@code ItemEvent.DESELECTED} 54 * </ul> 55 * Assigning the value different from listed above will cause an unspecified behavior. 56 * 57 * @author Carl Quinn 58 * 59 * @see java.awt.ItemSelectable 60 * @see ItemListener 81 82 /** 83 * This state-change value indicates that an item was selected. 84 */ 85 public static final int SELECTED = 1; 86 87 /** 88 * This state-change-value indicates that a selected item was deselected. 89 */ 90 public static final int DESELECTED = 2; 91 92 /** 93 * The item whose selection state has changed. 94 * 95 * @serial 96 * @see #getItem() 97 */ 98 Object item; 99 100 /** 101 * {@code stateChange} indicates whether the {@code item} 102 * was selected or deselected. 103 * 104 * @serial 105 * @see #getStateChange() 106 */ 107 int stateChange; 108 109 /* 110 * JDK 1.1 serialVersionUID 111 */ 112 private static final long serialVersionUID = -608708132447206933L; 113 114 /** 115 * Constructs an {@code ItemEvent} object. 116 * <p> This method throws an 117 * {@code IllegalArgumentException} if {@code source} 118 * is {@code null}. 119 * 120 * @param source The {@code ItemSelectable} object 121 * that originated the event 122 * @param id The integer that identifies the event type. 123 * For information on allowable values, see 124 * the class description for {@link ItemEvent} 125 * @param item An object -- the item affected by the event 126 * @param stateChange An integer that indicates whether the item was 127 * selected or deselected. 128 * For information on allowable values, see 129 * the class description for {@link ItemEvent} 130 * @throws IllegalArgumentException if {@code source} is null 131 * @see #getItemSelectable() 132 * @see #getID() 133 * @see #getStateChange() 134 */ 135 public ItemEvent(ItemSelectable source, int id, Object item, int stateChange) { 136 super(source, id); 137 this.item = item; 138 this.stateChange = stateChange; 139 } 140 141 /** 142 * Returns the originator of the event. 143 * 144 * @return the ItemSelectable object that originated the event. 145 */ 146 public ItemSelectable getItemSelectable() { 147 return (ItemSelectable)source; 148 } 149 150 /** |