86 |
|
|
87 |
protected AccessibleContext accessibleContext; |
protected AccessibleContext accessibleContext; |
88 |
|
|
|
/** |
|
|
* 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 |
public JWindow() |
public JWindow() |
90 |
{ |
{ |
91 |
super(SwingUtilities.getOwnerFrame()); |
super(SwingUtilities.getOwnerFrame()); |
121 |
super.setLayout(new BorderLayout(1, 1)); |
super.setLayout(new BorderLayout(1, 1)); |
122 |
getRootPane(); // will do set/create |
getRootPane(); // will do set/create |
123 |
// Now we're done init stage, adds and layouts go to content pane. |
// Now we're done init stage, adds and layouts go to content pane. |
124 |
initStageDone = true; |
setRootPaneCheckingEnabled(true); |
125 |
} |
} |
126 |
|
|
127 |
public Dimension getPreferredSize() |
public Dimension getPreferredSize() |
133 |
{ |
{ |
134 |
// Check if we're in initialization stage. If so, call super.setLayout |
// Check if we're in initialization stage. If so, call super.setLayout |
135 |
// otherwise, valid calls go to the content pane. |
// otherwise, valid calls go to the content pane. |
136 |
if (initStageDone) |
if (isRootPaneCheckingEnabled()) |
137 |
{ |
getContentPane().setLayout(manager); |
|
if (isRootPaneCheckingEnabled()) |
|
|
throw new Error("Cannot set layout. Use getContentPane().setLayout()" |
|
|
+ " instead."); |
|
|
getContentPane().setLayout(manager); |
|
|
} |
|
138 |
else |
else |
139 |
super.setLayout(manager); |
super.setLayout(manager); |
140 |
} |
} |
195 |
{ |
{ |
196 |
// If we're adding in the initialization stage use super.add. |
// If we're adding in the initialization stage use super.add. |
197 |
// otherwise pass the add onto the content pane. |
// otherwise pass the add onto the content pane. |
198 |
if (!initStageDone) |
if (isRootPaneCheckingEnabled()) |
199 |
super.addImpl(comp, constraints, index); |
getContentPane().add(comp, constraints, index); |
200 |
else |
else |
201 |
{ |
super.addImpl(comp, constraints, index); |
|
if (isRootPaneCheckingEnabled()) |
|
|
throw new Error("Do not use add() on JWindow directly. Use " |
|
|
+ "getContentPane().add() instead"); |
|
|
getContentPane().add(comp, constraints, index); |
|
|
} |
|
202 |
} |
} |
203 |
|
|
204 |
public void remove(Component comp) |
public void remove(Component comp) |