/[classpath]/classpath/javax/swing/JApplet.java
ViewVC logotype

Diff of /classpath/javax/swing/JApplet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by mkoch, Tue Jan 25 07:07:25 2005 UTC revision 1.16 by rabbit78, Fri Jun 17 11:53:50 2005 UTC
# Line 55  public class JApplet extends Applet Line 55  public class JApplet extends Applet
55    private static final long serialVersionUID = 7269359214497372587L;    private static final long serialVersionUID = 7269359214497372587L;
56        
57    protected JRootPane rootPane;    protected JRootPane rootPane;
58    protected boolean rootPaneCheckingEnabled;  
59      /**
60       * @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0
61       */
62      protected boolean rootPaneCheckingEnabled=false;
63    
64      /**
65       * Tells us if we're in the initialization stage.
66       * If so, adds go to top-level Container, otherwise they go
67       * to the content pane for this container
68       */
69      private boolean initStageDone = false;
70    
71    public JApplet()    public JApplet()
72    {    {
73      super.setLayout(new BorderLayout(1, 1));      super.setLayout(new BorderLayout(1, 1));
74      getRootPane(); // will do set/create      getRootPane(); // Will do set/create.
75        initStageDone = true; // Init stage is now over.
76    }    }
77    
78    public Dimension getPreferredSize()    public Dimension getPreferredSize()
# Line 70  public class JApplet extends Applet Line 82  public class JApplet extends Applet
82    
83    public void setLayout(LayoutManager manager)    public void setLayout(LayoutManager manager)
84    {    {
85      super.setLayout(manager);      // Check if we're in initialization stage.  If so, call super.setLayout
86        // otherwise, valid calls go to the content pane
87        if (initStageDone)
88          {
89            if (isRootPaneCheckingEnabled())
90              throw new Error("Cannot set layout. Use getContentPane().setLayout()"
91                               + "instead.");
92            getContentPane().setLayout(manager);
93          }
94        else
95          super.setLayout(manager);
96    }    }
97    
98    public void setLayeredPane(JLayeredPane layeredPane)    public void setLayeredPane(JLayeredPane layeredPane)
# Line 126  public class JApplet extends Applet Line 148  public class JApplet extends Applet
148    
149    protected void addImpl(Component comp, Object constraints, int index)    protected void addImpl(Component comp, Object constraints, int index)
150    {    {
151      super.addImpl(comp, constraints, index);      // If we're adding the rootPane (initialization stages) use super.add.
152        // Otherwise pass the add onto the content pane.
153        if (comp == rootPane)
154          super.addImpl(comp, constraints, index);
155        else
156          {
157            if (isRootPaneCheckingEnabled())
158              throw new Error("Do not use add() on JApplet directly. Use "
159                               + "getContentPane().add() instead");
160            getContentPane().add(comp, constraints, index);
161          }
162    }    }
163    
164    public AccessibleContext getAccessibleContext()    public AccessibleContext getAccessibleContext()
# Line 156  public class JApplet extends Applet Line 188  public class JApplet extends Applet
188        
189    public void remove(Component comp)    public void remove(Component comp)
190    {    {
191      getContentPane().remove(comp);      // If we're removing the root pane, use super.remove. Otherwise
192        // pass it on to the content pane instead
193        if (comp == rootPane)
194          super.remove(rootPane);
195        else
196          getContentPane().remove(comp);
197    }    }
198    
199    protected boolean isRootPaneCheckingEnabled()    protected boolean isRootPaneCheckingEnabled()

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26