38 |
|
|
39 |
package java.awt; |
package java.awt; |
40 |
|
|
41 |
|
import java.awt.event.PaintEvent; |
42 |
import javax.accessibility.Accessible; |
import javax.accessibility.Accessible; |
43 |
import javax.accessibility.AccessibleContext; |
import javax.accessibility.AccessibleContext; |
44 |
import javax.accessibility.AccessibleRole; |
import javax.accessibility.AccessibleRole; |
63 |
/** The cached accessible context. */ |
/** The cached accessible context. */ |
64 |
private transient AccessibleContext context; |
private transient AccessibleContext context; |
65 |
|
|
66 |
|
/** Flag set when the first system-requested paint event is |
67 |
|
dispatched. */ |
68 |
|
private transient boolean initialSystemUpdateDone; |
69 |
|
|
70 |
|
/** Flag set when the first application-requested paint event is |
71 |
|
consumed. */ |
72 |
|
private transient boolean initialUpdateConsumed; |
73 |
|
|
74 |
|
/* |
75 |
|
* The number used to generate the name returned by getName. |
76 |
|
*/ |
77 |
|
private static transient long next_panel_number = 0; |
78 |
|
|
79 |
/** |
/** |
80 |
* Initializes a new instance of <code>Panel</code> that has a default |
* Initializes a new instance of <code>Panel</code> that has a default |
81 |
* layout manager of <code>FlowLayout</code>. |
* layout manager of <code>FlowLayout</code>. |
98 |
} |
} |
99 |
|
|
100 |
/** |
/** |
101 |
|
* Consume initial application-requested paint event if it has not |
102 |
|
* already been consumed, and if the initial system-requested paint |
103 |
|
* event has not already been handled. Otherwise, call |
104 |
|
* super.dispatchEventImpl. These extra steps are required to |
105 |
|
* prevent a Panel from being painted twice when it is initially |
106 |
|
* shown. |
107 |
|
* |
108 |
|
* @param e the event to dispatch |
109 |
|
*/ |
110 |
|
void dispatchEventImpl (AWTEvent e) |
111 |
|
{ |
112 |
|
if (e instanceof PaintEvent) |
113 |
|
{ |
114 |
|
if (e.id == PaintEvent.UPDATE) |
115 |
|
{ |
116 |
|
if (!initialUpdateConsumed |
117 |
|
&& !initialSystemUpdateDone) |
118 |
|
{ |
119 |
|
e.consume (); |
120 |
|
initialUpdateConsumed = true; |
121 |
|
} |
122 |
|
} |
123 |
|
else if (e.id == PaintEvent.PAINT) |
124 |
|
initialSystemUpdateDone = true; |
125 |
|
} |
126 |
|
else |
127 |
|
super.dispatchEventImpl (e); |
128 |
|
} |
129 |
|
|
130 |
|
/** |
131 |
* Notifies this object to create its native peer. |
* Notifies this object to create its native peer. |
132 |
* |
* |
133 |
* @see #isDisplayable() |
* @see #isDisplayable() |
185 |
{ |
{ |
186 |
return AccessibleRole.PANEL; |
return AccessibleRole.PANEL; |
187 |
} |
} |
188 |
} // class AccessibleAWTPanel |
} |
189 |
} // class Panel |
|
190 |
|
/** |
191 |
|
* Generate a unique name for this panel. |
192 |
|
* |
193 |
|
* @return A unique name for this panel. |
194 |
|
*/ |
195 |
|
String generateName () |
196 |
|
{ |
197 |
|
return "panel" + getUniqueLong (); |
198 |
|
} |
199 |
|
|
200 |
|
private static synchronized long getUniqueLong () |
201 |
|
{ |
202 |
|
return next_panel_number++; |
203 |
|
} |
204 |
|
} |