102 |
*/ |
*/ |
103 |
protected boolean rootPaneCheckingEnabled = false; |
protected boolean rootPaneCheckingEnabled = false; |
104 |
|
|
|
/** |
|
|
* 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; |
|
|
|
|
105 |
public JFrame() |
public JFrame() |
106 |
{ |
{ |
107 |
super("JFrame"); |
super("JFrame"); |
151 |
enableEvents(AWTEvent.WINDOW_EVENT_MASK); |
enableEvents(AWTEvent.WINDOW_EVENT_MASK); |
152 |
getRootPane(); // will do set/create |
getRootPane(); // will do set/create |
153 |
// We're now done the init stage. |
// We're now done the init stage. |
154 |
initStageDone = true; |
setRootPaneCheckingEnabled(true); |
155 |
} |
} |
156 |
|
|
157 |
public Dimension getPreferredSize() |
public Dimension getPreferredSize() |
173 |
{ |
{ |
174 |
// Check if we're in initialization stage. If so, call super.setLayout |
// Check if we're in initialization stage. If so, call super.setLayout |
175 |
// otherwise, valid calls go to the content pane. |
// otherwise, valid calls go to the content pane. |
176 |
if (initStageDone) |
if (isRootPaneCheckingEnabled()) |
177 |
{ |
getContentPane().setLayout(manager); |
|
if (isRootPaneCheckingEnabled()) |
|
|
throw new Error("Cannot set layout. Use getContentPane().setLayout()" |
|
|
+ " instead."); |
|
|
getContentPane().setLayout(manager); |
|
|
} |
|
178 |
else |
else |
179 |
super.setLayout(manager); |
super.setLayout(manager); |
180 |
} |
} |
234 |
{ |
{ |
235 |
// If we're adding in the initialization stage use super.add. |
// If we're adding in the initialization stage use super.add. |
236 |
// Otherwise pass the add onto the content pane. |
// Otherwise pass the add onto the content pane. |
237 |
if (!initStageDone) |
if (isRootPaneCheckingEnabled()) |
238 |
super.addImpl(comp, constraints, index); |
getContentPane().add(comp,constraints,index); |
239 |
else |
else |
240 |
{ |
super.addImpl(comp, constraints, index); |
|
if (isRootPaneCheckingEnabled()) |
|
|
throw new Error("rootPaneChecking is enabled - adding components " |
|
|
+ "disallowed."); |
|
|
getContentPane().add(comp,constraints,index); |
|
|
} |
|
241 |
} |
} |
242 |
|
|
243 |
public void remove(Component comp) |
public void remove(Component comp) |