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

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

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

revision 1.10 by mark, Sat Jun 26 16:07:01 2004 UTC revision 1.11 by mark, Thu Jul 22 19:45:39 2004 UTC
# Line 48  import javax.accessibility.AccessibleRol Line 48  import javax.accessibility.AccessibleRol
48  import javax.swing.plaf.RootPaneUI;  import javax.swing.plaf.RootPaneUI;
49    
50  /**  /**
51   * This class is where JComponents are added to.   * This class is where JComponents are added to. Unlike awt where you could
52   * Unlike awt where you could just say frame.add(),   * just say frame.add(), with swing you need to say frame.getRootPane()
53   * with swing you need to say frame.getRootPane()   * (which delivers an instance of this class) and add your components to
54   * (which delivers an instance of this class)   * that. It is implemented by several 'layers' (pane() should be read as
55   * and add your components to that.   * plane()) each on top of the others where you can add components to.
  *  
  * It is implemented by several 'layers' (pane() should be read as plane())  
  * each on top of the others  
  * where you can add components to.  
56   * (getContentPane(), getGlassPane(), getLayeredPane())   * (getContentPane(), getGlassPane(), getLayeredPane())
57   *   *
58   * @author Ronald Veldema (rveldema@cs.vu.nl)   * @author Ronald Veldema (rveldema@cs.vu.nl)
# Line 66  public class JRootPane extends JComponen Line 62  public class JRootPane extends JComponen
62    //  The class used to obtain the accessible role for this object.    //  The class used to obtain the accessible role for this object.
63    protected static class AccessibleJRootPane    protected static class AccessibleJRootPane
64    {    {
65        /** DOCUMENT ME! */
66      private static final long serialVersionUID = 1082432482784468088L;      private static final long serialVersionUID = 1082432482784468088L;
67    
68        /**
69         * Creates a new <code>AccessibleJRootPane</code> object.
70         */
71      protected AccessibleJRootPane()      protected AccessibleJRootPane()
72      {      {
73      }      }
74    
75        /**
76         * DOCUMENT ME!
77         *
78         * @return DOCUMENT ME!
79         */
80      public AccessibleRole getAccessibleRole()      public AccessibleRole getAccessibleRole()
81      {      {
82        return AccessibleRole.ROOT_PANE;        return AccessibleRole.ROOT_PANE;
# Line 82  public class JRootPane extends JComponen Line 87  public class JRootPane extends JComponen
87    // menuBar withing its layeredPane.    // menuBar withing its layeredPane.
88    protected class RootLayout implements LayoutManager2, Serializable    protected class RootLayout implements LayoutManager2, Serializable
89    {    {
90        /** DOCUMENT ME! */
91      private static final long serialVersionUID = -4100116998559815027L;      private static final long serialVersionUID = -4100116998559815027L;
92    
93        /**
94         * Creates a new <code>RootLayout</code> object.
95         */
96      protected RootLayout()      protected RootLayout()
97      {      {
98      }      }
99            
100        /**
101         * DOCUMENT ME!
102         *
103         * @param comp DOCUMENT ME!
104         * @param constraints DOCUMENT ME!
105         */
106      public void addLayoutComponent(Component comp, Object constraints)      public void addLayoutComponent(Component comp, Object constraints)
107      {      {
108      }      }
109    
110        /**
111         * DOCUMENT ME!
112         *
113         * @param name DOCUMENT ME!
114         * @param comp DOCUMENT ME!
115         */
116      public void addLayoutComponent(String name, Component comp)      public void addLayoutComponent(String name, Component comp)
117      {      {
118      }      }
119    
120        /**
121         * DOCUMENT ME!
122         *
123         * @param target DOCUMENT ME!
124         *
125         * @return DOCUMENT ME!
126         */
127      public float getLayoutAlignmentX(Container target)      public float getLayoutAlignmentX(Container target)
128      {      {
129        return target.getAlignmentX();        return target.getAlignmentX();
130      }      }
131    
132        /**
133         * DOCUMENT ME!
134         *
135         * @param target DOCUMENT ME!
136         *
137         * @return DOCUMENT ME!
138         */
139      public float getLayoutAlignmentY(Container target)      public float getLayoutAlignmentY(Container target)
140      {      {
141        return target.getAlignmentY();        return target.getAlignmentY();
142      }      }
143    
144        /**
145         * DOCUMENT ME!
146         *
147         * @param target DOCUMENT ME!
148         */
149      public void invalidateLayout(Container target)      public void invalidateLayout(Container target)
150      {      {
151      }      }
152    
153        /**
154         * DOCUMENT ME!
155         *
156         * @param c DOCUMENT ME!
157         */
158      public void layoutContainer(Container c)      public void layoutContainer(Container c)
159      {      {
160        Dimension menuBarSize;        Dimension menuBarSize;
# Line 146  public class JRootPane extends JComponen Line 191  public class JRootPane extends JComponen
191                menuBarSize = menuBar.getPreferredSize();                menuBarSize = menuBar.getPreferredSize();
192                maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);                maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
193                menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);                menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
194                  glassPane.setBounds(0, menuBarSize.height, maxWidth,
195                                      contentPaneSize.height);
196                contentPane.setBounds(0, menuBarSize.height, maxWidth,                contentPane.setBounds(0, menuBarSize.height, maxWidth,
197                                      contentPaneSize.height);                                      contentPaneSize.height);
198                layeredPane.setSize(maxWidth,                layeredPane.setSize(maxWidth,
# Line 153  public class JRootPane extends JComponen Line 200  public class JRootPane extends JComponen
200              }              }
201            else            else
202              {              {
203                  glassPane.setBounds(0, 0, contentPaneSize.width,
204                                      contentPaneSize.height);
205                contentPane.setBounds(0, 0, contentPaneSize.width,                contentPane.setBounds(0, 0, contentPaneSize.width,
206                                      contentPaneSize.height);                                      contentPaneSize.height);
207                layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);                layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
# Line 167  public class JRootPane extends JComponen Line 216  public class JRootPane extends JComponen
216                  menuBarSize.height = containerSize.height;                  menuBarSize.height = containerSize.height;
217                menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);                menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
218                int remainingHeight = containerSize.height - menuBarSize.height;                int remainingHeight = containerSize.height - menuBarSize.height;
219                  glassPane.setBounds(0, menuBarSize.height, containerSize.width,
220                                      containerSize.height - menuBarSize.height);
221                contentPane.setBounds(0, menuBarSize.height,                contentPane.setBounds(0, menuBarSize.height,
222                                      containerSize.width,                                      containerSize.width,
223                                      (containerSize.height - menuBarSize.height));                                      (containerSize.height - menuBarSize.height));
224              }              }
225            else            else
226                {
227                  glassPane.setBounds(0, 0, containerSize.width,
228                                      containerSize.height);
229              contentPane.setBounds(0, 0, containerSize.width,              contentPane.setBounds(0, 0, containerSize.width,
230                                    containerSize.height);                                    containerSize.height);
231                }
232    
233            layeredPane.setSize(containerSize.width, containerSize.height);            layeredPane.setSize(containerSize.width, containerSize.height);
234          }          }
235      }      }
236    
237        /**
238         * DOCUMENT ME!
239         *
240         * @param target DOCUMENT ME!
241         *
242         * @return DOCUMENT ME!
243         */
244      public Dimension maximumLayoutSize(Container target)      public Dimension maximumLayoutSize(Container target)
245      {      {
246        return preferredLayoutSize(target);        return preferredLayoutSize(target);
247      }      }
248    
249        /**
250         * DOCUMENT ME!
251         *
252         * @param target DOCUMENT ME!
253         *
254         * @return DOCUMENT ME!
255         */
256      public Dimension minimumLayoutSize(Container target)      public Dimension minimumLayoutSize(Container target)
257      {      {
258        return preferredLayoutSize(target);        return preferredLayoutSize(target);
259      }      }
260    
261        /**
262         * DOCUMENT ME!
263         *
264         * @param c DOCUMENT ME!
265         *
266         * @return DOCUMENT ME!
267         */
268      public Dimension preferredLayoutSize(Container c)      public Dimension preferredLayoutSize(Container c)
269      {      {
270        Dimension menuBarSize;        Dimension menuBarSize;
# Line 204  public class JRootPane extends JComponen Line 280  public class JRootPane extends JComponen
280                int maxWidth;                int maxWidth;
281                menuBarSize = menuBar.getPreferredSize();                menuBarSize = menuBar.getPreferredSize();
282                maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);                maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
283                prefSize =                prefSize = new Dimension(maxWidth,
284                  new Dimension(maxWidth,                                         contentPaneSize.height
285                                contentPaneSize.height + menuBarSize.height);                                         + menuBarSize.height);
286              }              }
287            else            else
288              prefSize = contentPaneSize;              prefSize = contentPaneSize;
# Line 217  public class JRootPane extends JComponen Line 293  public class JRootPane extends JComponen
293        return prefSize;        return prefSize;
294      }      }
295    
296        /**
297         * DOCUMENT ME!
298         *
299         * @param comp DOCUMENT ME!
300         */
301      public void removeLayoutComponent(Component comp)      public void removeLayoutComponent(Component comp)
302      {      {
303      }      }
304    }    }
305    
306      /** DOCUMENT ME! */
307      private static final long serialVersionUID = 8690748000348575668L;
308    
309      /** DOCUMENT ME! */
310    protected Component glassPane;    protected Component glassPane;
311    
312      /** DOCUMENT ME! */
313    protected JLayeredPane layeredPane;    protected JLayeredPane layeredPane;
314    
315      /** DOCUMENT ME! */
316    protected JMenuBar menuBar;    protected JMenuBar menuBar;
317    
318      /** DOCUMENT ME! */
319    protected Container contentPane;    protected Container contentPane;
320    
321      /**
322       * DOCUMENT ME!
323       *
324       * @param m DOCUMENT ME!
325       */
326    public void setJMenuBar(JMenuBar m)    public void setJMenuBar(JMenuBar m)
327    {    {
328      menuBar = m;      menuBar = m;
329      getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);      getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
330    }    }
331    
332      /**
333       * DOCUMENT ME!
334       *
335       * @return DOCUMENT ME!
336       */
337    public JMenuBar getJMenuBar()    public JMenuBar getJMenuBar()
338    {    {
339      return menuBar;      return menuBar;
340    }    }
341    
342      /**
343       * DOCUMENT ME!
344       *
345       * @return DOCUMENT ME!
346       */
347    public boolean isValidateRoot()    public boolean isValidateRoot()
348    {    {
349      return true;      return true;
350    }    }
351    
352      /**
353       * DOCUMENT ME!
354       *
355       * @return DOCUMENT ME!
356       */
357    public Container getContentPane()    public Container getContentPane()
358    {    {
359      if (contentPane == null)      if (contentPane == null)
# Line 250  public class JRootPane extends JComponen Line 361  public class JRootPane extends JComponen
361      return contentPane;      return contentPane;
362    }    }
363    
364      /**
365       * DOCUMENT ME!
366       *
367       * @param p DOCUMENT ME!
368       */
369    public void setContentPane(Container p)    public void setContentPane(Container p)
370    {    {
371      contentPane = p;      contentPane = p;
372      getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);      getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
373    }    }
374    
375      /**
376       * DOCUMENT ME!
377       *
378       * @param comp DOCUMENT ME!
379       * @param constraints DOCUMENT ME!
380       * @param index DOCUMENT ME!
381       */
382    protected void addImpl(Component comp, Object constraints, int index)    protected void addImpl(Component comp, Object constraints, int index)
383    {    {
384      super.addImpl(comp, constraints, index);      super.addImpl(comp, constraints, index);
385    }    }
386    
387      /**
388       * DOCUMENT ME!
389       *
390       * @return DOCUMENT ME!
391       */
392    public Component getGlassPane()    public Component getGlassPane()
393    {    {
394      if (glassPane == null)      if (glassPane == null)
# Line 268  public class JRootPane extends JComponen Line 396  public class JRootPane extends JComponen
396      return glassPane;      return glassPane;
397    }    }
398    
399      /**
400       * DOCUMENT ME!
401       *
402       * @param f DOCUMENT ME!
403       */
404    public void setGlassPane(Component f)    public void setGlassPane(Component f)
405    {    {
406      if (glassPane != null)      if (glassPane != null)
# Line 279  public class JRootPane extends JComponen Line 412  public class JRootPane extends JComponen
412      add(glassPane, 0);      add(glassPane, 0);
413    }    }
414    
415      /**
416       * DOCUMENT ME!
417       *
418       * @return DOCUMENT ME!
419       */
420    public JLayeredPane getLayeredPane()    public JLayeredPane getLayeredPane()
421    {    {
422      if (layeredPane == null)      if (layeredPane == null)
# Line 286  public class JRootPane extends JComponen Line 424  public class JRootPane extends JComponen
424      return layeredPane;      return layeredPane;
425    }    }
426    
427      /**
428       * DOCUMENT ME!
429       *
430       * @param f DOCUMENT ME!
431       */
432    public void setLayeredPane(JLayeredPane f)    public void setLayeredPane(JLayeredPane f)
433    {    {
434      if (layeredPane != null)      if (layeredPane != null)
# Line 295  public class JRootPane extends JComponen Line 438  public class JRootPane extends JComponen
438      add(f, -1);      add(f, -1);
439    }    }
440    
441      /**
442       * Creates a new <code>JRootPane</code> object.
443       */
444    public JRootPane()    public JRootPane()
445    {    {
446      setLayout(createRootLayout());      setLayout(createRootLayout());
# Line 305  public class JRootPane extends JComponen Line 451  public class JRootPane extends JComponen
451      updateUI();      updateUI();
452    }    }
453    
454      /**
455       * DOCUMENT ME!
456       *
457       * @return DOCUMENT ME!
458       */
459    protected LayoutManager createRootLayout()    protected LayoutManager createRootLayout()
460    {    {
461      return new RootLayout();      return new RootLayout();
462    }    }
463    
464      /**
465       * DOCUMENT ME!
466       *
467       * @return DOCUMENT ME!
468       */
469    protected JComponent createContentPane()    protected JComponent createContentPane()
470    {    {
471      JPanel p = new JPanel();      JPanel p = new JPanel();
# Line 318  public class JRootPane extends JComponen Line 474  public class JRootPane extends JComponen
474      return p;      return p;
475    }    }
476    
477      /**
478       * DOCUMENT ME!
479       *
480       * @return DOCUMENT ME!
481       */
482    protected Component createGlassPane()    protected Component createGlassPane()
483    {    {
484      JPanel p = new JPanel();      JPanel p = new JPanel();
485      p.setName(this.getName() + ".glassPane");      p.setName(this.getName() + ".glassPane");
486      p.setLayout(new BorderLayout());      p.setLayout(new BorderLayout());
487      p.setVisible(false);      p.setVisible(false);
488        p.setOpaque(false);
489      return p;      return p;
490    }    }
491    
492      /**
493       * DOCUMENT ME!
494       *
495       * @return DOCUMENT ME!
496       */
497    protected JLayeredPane createLayeredPane()    protected JLayeredPane createLayeredPane()
498    {    {
499      JLayeredPane l = new JLayeredPane();      JLayeredPane l = new JLayeredPane();
# Line 334  public class JRootPane extends JComponen Line 501  public class JRootPane extends JComponen
501      return l;      return l;
502    }    }
503    
504      /**
505       * DOCUMENT ME!
506       *
507       * @return DOCUMENT ME!
508       */
509    public RootPaneUI getUI()    public RootPaneUI getUI()
510    {    {
511      return (RootPaneUI) ui;      return (RootPaneUI) ui;
512    }    }
513    
514      /**
515       * DOCUMENT ME!
516       *
517       * @param ui DOCUMENT ME!
518       */
519    public void setUI(RootPaneUI ui)    public void setUI(RootPaneUI ui)
520    {    {
521      super.setUI(ui);      super.setUI(ui);
522    }    }
523    
524      /**
525       * DOCUMENT ME!
526       */
527    public void updateUI()    public void updateUI()
528    {    {
529      setUI((RootPaneUI) UIManager.getUI(this));      setUI((RootPaneUI) UIManager.getUI(this));
530    }    }
531    
532      /**
533       * DOCUMENT ME!
534       *
535       * @return DOCUMENT ME!
536       */
537    public String getUIClassID()    public String getUIClassID()
538    {    {
539      return "RootPaneUI";      return "RootPaneUI";

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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