85 |
/** |
/** |
86 |
* @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0 |
* @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0 |
87 |
*/ |
*/ |
88 |
protected boolean rootPaneCheckingEnabled=false; |
protected boolean rootPaneCheckingEnabled = false; |
|
|
|
|
/** |
|
|
* Tells us if we're in the initialization stage. |
|
|
* If so, adds go to top-level Container, otherwise they go |
|
|
* to the content pane for this container |
|
|
*/ |
|
|
private boolean initStageDone = false; |
|
89 |
|
|
90 |
public JApplet() |
public JApplet() |
91 |
{ |
{ |
92 |
super.setLayout(new BorderLayout(1, 1)); |
super.setLayout(new BorderLayout(1, 1)); |
93 |
getRootPane(); // Will do set/create. |
getRootPane(); // Will do set/create. |
94 |
initStageDone = true; // Init stage is now over. |
setRootPaneCheckingEnabled(true); // Init stage is now over. |
95 |
} |
} |
96 |
|
|
97 |
public Dimension getPreferredSize() |
public Dimension getPreferredSize() |
103 |
{ |
{ |
104 |
// Check if we're in initialization stage. If so, call super.setLayout |
// Check if we're in initialization stage. If so, call super.setLayout |
105 |
// otherwise, valid calls go to the content pane |
// otherwise, valid calls go to the content pane |
106 |
if (initStageDone) |
if (isRootPaneCheckingEnabled()) |
107 |
{ |
getContentPane().setLayout(manager); |
|
if (isRootPaneCheckingEnabled()) |
|
|
throw new Error("Cannot set layout. Use getContentPane().setLayout()" |
|
|
+ "instead."); |
|
|
getContentPane().setLayout(manager); |
|
|
} |
|
108 |
else |
else |
109 |
super.setLayout(manager); |
super.setLayout(manager); |
110 |
} |
} |
164 |
{ |
{ |
165 |
// If we're adding in the initialization stage use super.add. |
// If we're adding in the initialization stage use super.add. |
166 |
// Otherwise pass the add onto the content pane. |
// Otherwise pass the add onto the content pane. |
167 |
if (!initStageDone) |
if (isRootPaneCheckingEnabled()) |
168 |
super.addImpl(comp, constraints, index); |
getContentPane().add(comp, constraints, index); |
169 |
else |
else |
170 |
{ |
super.addImpl(comp, constraints, index); |
|
if (isRootPaneCheckingEnabled()) |
|
|
throw new Error("Do not use add() on JApplet directly. Use " |
|
|
+ "getContentPane().add() instead"); |
|
|
getContentPane().add(comp, constraints, index); |
|
|
} |
|
171 |
} |
} |
172 |
|
|
173 |
public AccessibleContext getAccessibleContext() |
public AccessibleContext getAccessibleContext() |
189 |
|
|
190 |
protected String paramString() |
protected String paramString() |
191 |
{ |
{ |
192 |
return "JFrame"; |
return super.paramString(); |
193 |
} |
} |
194 |
|
|
195 |
protected void processKeyEvent(KeyEvent e) |
protected void processKeyEvent(KeyEvent e) |