01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Michael Danilov
19: * @version $Revision$
20: */package java.awt.event;
21:
22: import java.awt.AWTEvent;
23: import java.awt.ItemSelectable;
24:
25: public class ItemEvent extends AWTEvent {
26:
27: private static final long serialVersionUID = -608708132447206933L;
28:
29: public static final int ITEM_FIRST = 701;
30:
31: public static final int ITEM_LAST = 701;
32:
33: public static final int ITEM_STATE_CHANGED = 701;
34:
35: public static final int SELECTED = 1;
36:
37: public static final int DESELECTED = 2;
38:
39: private Object item;
40: private int stateChange;
41:
42: public ItemEvent(ItemSelectable source, int id, Object item,
43: int stateChange) {
44: super (source, id);
45:
46: this .item = item;
47: this .stateChange = stateChange;
48: }
49:
50: public Object getItem() {
51: return item;
52: }
53:
54: public int getStateChange() {
55: return stateChange;
56: }
57:
58: public ItemSelectable getItemSelectable() {
59: return (ItemSelectable) source;
60: }
61:
62: @Override
63: public String paramString() {
64: /* The format is based on 1.5 release behavior
65: * which can be revealed by the following code:
66: *
67: * Checkbox c = new Checkbox("Checkbox", true);
68: * ItemEvent e = new ItemEvent(c, ItemEvent.ITEM_STATE_CHANGED,
69: * c, ItemEvent.SELECTED);
70: * System.out.println(e);
71: */
72:
73: String stateString = null;
74:
75: switch (stateChange) {
76: case SELECTED:
77: stateString = "SELECTED"; //$NON-NLS-1$
78: break;
79: case DESELECTED:
80: stateString = "DESELECTED"; //$NON-NLS-1$
81: break;
82: default:
83: stateString = "unknown type"; //$NON-NLS-1$
84: }
85:
86: return ((id == ITEM_STATE_CHANGED ? "ITEM_STATE_CHANGED" : "unknown type") + //$NON-NLS-1$ //$NON-NLS-2$
87: ",item=" + item + ",stateChange=" + stateString); //$NON-NLS-1$ //$NON-NLS-2$
88: }
89:
90: }
|