summaryrefslogtreecommitdiff
path: root/javax/swing/JInternalFrame.java
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/JInternalFrame.java')
-rw-r--r--javax/swing/JInternalFrame.java71
1 files changed, 50 insertions, 21 deletions
diff --git a/javax/swing/JInternalFrame.java b/javax/swing/JInternalFrame.java
index 8a29d2fff..b504aaaa5 100644
--- a/javax/swing/JInternalFrame.java
+++ b/javax/swing/JInternalFrame.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -430,8 +430,19 @@ public class JInternalFrame extends JComponent implements Accessible,
/** Whether the JInternalFrame can be maximized. */
protected boolean maximizable;
- /** Whether the JInternalFrame has rootPaneChecking enabled. */
- protected boolean rootPaneCheckingEnabled = true;
+ /**
+ * Whether the JInternalFrame has rootPaneChecking enabled.
+ *
+ * @specnote Should be false to comply with J2SE 5.0
+ */
+ 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;
/** Whether the JInternalFrame is resizable. */
protected boolean resizable;
@@ -554,12 +565,9 @@ public class JInternalFrame extends JComponent implements Accessible,
this.maximizable = maximizable;
this.iconable = iconifiable;
storedBounds = new Rectangle();
-
- setRootPaneCheckingEnabled(false);
setRootPane(createRootPane());
-
updateUI();
- setRootPaneCheckingEnabled(true);
+ initStageDone = true; // Done the init stage, now adds go to content pane.
}
/**
@@ -576,10 +584,18 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
protected void addImpl(Component comp, Object constraints, int index)
{
- if (isRootPaneCheckingEnabled())
- throw new Error("Do not use add() on JInternalPane directly. Use getContentPane().add() instead");
-
- super.addImpl(comp, constraints, index);
+ // If we're in the initialization stage use super.add. Here we add the
+ // rootPane as well as the title bar and other stuff.
+ // Otherwise pass the add onto the content pane.
+ if (!initStageDone)
+ super.addImpl(comp,constraints, index);
+ else
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Do not use add() on JInternalFrame directly. Use "
+ + "getContentPane().add() instead");
+ getContentPane().add(comp, constraints, index);
+ }
}
/**
@@ -1150,7 +1166,7 @@ public class JInternalFrame extends JComponent implements Accessible,
{
// Do nothing if they don't want to be restored first.
}
- doLayout();
+ setSize(getPreferredSize());
}
/**
@@ -1181,7 +1197,12 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void remove(Component comp)
{
- super.remove(comp);
+ // If we're removing the root pane, use super.remove. Otherwise
+ // pass it on to the content pane instead.
+ if (comp==rootPane)
+ super.remove(comp);
+ else
+ getContentPane().remove(comp);
}
/**
@@ -1285,10 +1306,10 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setDefaultCloseOperation(int operation)
{
- if (operation != DO_NOTHING_ON_CLOSE
- && operation != HIDE_ON_CLOSE
- && operation != DISPOSE_ON_CLOSE)
- throw new Error("Close operation must be one of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
+ /* Reference implementation allows invalid operations to be specified.
+ In that case, behaviour defaults to DO_NOTHING_ON_CLOSE.
+ processWindowEvent handles the behaviour. getDefaultCloseOperation
+ must return the invalid operator code. */
defaultCloseOperation = operation;
}
@@ -1466,9 +1487,17 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setLayout(LayoutManager manager)
{
- if (isRootPaneCheckingEnabled())
- throw new Error("Cannot set layout. Use getContentPane().setLayout() instead.");
- super.setLayout(manager);
+ // Check if we're in initialization stage. If so, call super.setLayout
+ // otherwise, valid calls go to the content pane.
+ if (initStageDone)
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Cannot set layout. Use getContentPane().setLayout()"
+ + " instead.");
+ getContentPane().setLayout(manager);
+ }
+ else
+ super.setLayout(manager);
}
/**