/[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.12.2.7 by gnu_andrew, Sat Sep 10 15:31:49 2005 UTC revision 1.12.2.8 by gnu_andrew, Tue Sep 20 18:46:31 2005 UTC
# Line 42  import java.awt.BorderLayout; Line 42  import java.awt.BorderLayout;
42  import java.awt.Component;  import java.awt.Component;
43  import java.awt.Container;  import java.awt.Container;
44  import java.awt.Dimension;  import java.awt.Dimension;
45    import java.awt.IllegalComponentStateException;
46  import java.awt.LayoutManager;  import java.awt.LayoutManager;
47  import java.awt.LayoutManager2;  import java.awt.LayoutManager2;
48  import java.io.Serializable;  import java.io.Serializable;
# Line 163  public class JRootPane extends JComponen Line 164  public class JRootPane extends JComponen
164      public void layoutContainer(Container c)      public void layoutContainer(Container c)
165      {      {
166        Dimension menuBarSize;        Dimension menuBarSize;
167        Dimension containerSize = c.getSize(null);        int containerWidth = c.getBounds().width - getInsets().left
168                               - getInsets().right;
169          int containerHeight = c.getBounds().height - getInsets().top
170                                - getInsets().bottom;
171        Dimension contentPaneSize = contentPane.getPreferredSize();        Dimension contentPaneSize = contentPane.getPreferredSize();
172    
173          // 1. the glassPane fills entire viewable region (bounds - insets).
174          // 2. the layeredPane filles entire viewable region.
175          // 3. the menuBar is positioned at the upper edge of layeredPane.
176          // 4. the contentPane fills viewable region minus menuBar, if present.
177          
178        /*        /*
179         if size of top-level window wasn't set then just set         if size of top-level window wasn't set then just set
180         contentPane and menuBar to its preferred sizes.         contentPane and menuBar to its preferred sizes.
# Line 188  public class JRootPane extends JComponen Line 197  public class JRootPane extends JComponen
197         +-------------------------------+         +-------------------------------+
198    
199        */        */
200        if (containerSize.width == 0 && containerSize.height == 0)        if (containerWidth == 0 && containerHeight == 0)
201          {          {
202            if (menuBar != null)            if (menuBar != null)
203              {              {
# Line 196  public class JRootPane extends JComponen Line 205  public class JRootPane extends JComponen
205                menuBarSize = menuBar.getPreferredSize();                menuBarSize = menuBar.getPreferredSize();
206                maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);                maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
207                menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);                menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
208                glassPane.setBounds(0, menuBarSize.height, maxWidth,                glassPane.setBounds(0, 0, maxWidth, menuBarSize.height
209                                    contentPaneSize.height);                                                    + contentPaneSize.height);
210                contentPane.setBounds(0, menuBarSize.height, maxWidth,                contentPane.setBounds(0, menuBarSize.height, maxWidth,
211                                      contentPaneSize.height);                                      contentPaneSize.height);
212                layeredPane.setSize(maxWidth,                layeredPane.setBounds(0, 0, maxWidth, menuBarSize.height
213                                    menuBarSize.height + contentPaneSize.height);                                                      + contentPaneSize.height);
214              }              }
215            else            else
216              {              {
# Line 209  public class JRootPane extends JComponen Line 218  public class JRootPane extends JComponen
218                                    contentPaneSize.height);                                    contentPaneSize.height);
219                contentPane.setBounds(0, 0, contentPaneSize.width,                contentPane.setBounds(0, 0, contentPaneSize.width,
220                                      contentPaneSize.height);                                      contentPaneSize.height);
221                layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);                layeredPane.setBounds(0, 0, contentPaneSize.width,
222                                        contentPaneSize.height);
223              }              }
224          }          }
225        else        else
# Line 217  public class JRootPane extends JComponen Line 227  public class JRootPane extends JComponen
227            if (menuBar != null)            if (menuBar != null)
228              {              {
229                menuBarSize = menuBar.getPreferredSize();                menuBarSize = menuBar.getPreferredSize();
230                if (menuBarSize.height > containerSize.height)                if (menuBarSize.height > containerHeight)
231                  menuBarSize.height = containerSize.height;                  menuBarSize.height = containerHeight;
232                menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);                menuBar.setBounds(0, 0, containerWidth, menuBarSize.height);
233                int remainingHeight = containerSize.height - menuBarSize.height;                glassPane.setBounds(0, 0, containerWidth, containerHeight);
234                glassPane.setBounds(0, menuBarSize.height, containerSize.width,                contentPane.setBounds(0, menuBarSize.height, containerWidth,
235                                    containerSize.height - menuBarSize.height);                                      (containerHeight - menuBarSize.height));
               contentPane.setBounds(0, menuBarSize.height,  
                                     containerSize.width,  
                                     (containerSize.height - menuBarSize.height));  
236              }              }
237            else            else
238              {              {
239                glassPane.setBounds(0, 0, containerSize.width,                glassPane.setBounds(0, 0, containerWidth, containerHeight);
240                                    containerSize.height);                contentPane.setBounds(0, 0, containerWidth, containerHeight);
               contentPane.setBounds(0, 0, containerSize.width,  
                                     containerSize.height);  
241              }              }
242              layeredPane.setBounds(0, 0, containerWidth, containerHeight);
           layeredPane.setSize(containerSize.width, containerSize.height);  
243          }          }
244      }      }
245    
# Line 404  public class JRootPane extends JComponen Line 408  public class JRootPane extends JComponen
408    }    }
409    
410    /**    /**
411     * DOCUMENT ME!     * Sets the JRootPane's content pane.  The content pane should typically be
412       * opaque for painting to work properly.  This method also
413       * removes the old content pane from the layered pane.
414     *     *
415     * @param p DOCUMENT ME!     * @param p the Container that will be the content pane
416       * @throws IllegalComponentStateException if p is null
417     */     */
418    public void setContentPane(Container p)    public void setContentPane(Container p)
419    {    {
420      contentPane = p;      if (p == null)
421      getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);        throw new IllegalComponentStateException ("cannot " +
422                "have a null content pane");
423        else
424          {
425            if (contentPane != null && contentPane.getParent() == layeredPane)
426              layeredPane.remove(contentPane);
427            contentPane = p;
428            getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
429          }
430    }    }
431    
432    /**    /**
# Line 525  public class JRootPane extends JComponen Line 540  public class JRootPane extends JComponen
540    {    {
541      JPanel p = new JPanel();      JPanel p = new JPanel();
542      p.setName(this.getName() + ".glassPane");      p.setName(this.getName() + ".glassPane");
     p.setLayout(new BorderLayout());  
543      p.setVisible(false);      p.setVisible(false);
544      p.setOpaque(false);      p.setOpaque(false);
545      return p;      return p;
# Line 616  public class JRootPane extends JComponen Line 630  public class JRootPane extends JComponen
630          && style != COLOR_CHOOSER_DIALOG          && style != COLOR_CHOOSER_DIALOG
631          && style != FILE_CHOOSER_DIALOG          && style != FILE_CHOOSER_DIALOG
632          && style != QUESTION_DIALOG          && style != QUESTION_DIALOG
633          && style != WARNING_DIALOG)          && style != WARNING_DIALOG
634            && style != PLAIN_DIALOG)
635        throw new IllegalArgumentException("invalid style");        throw new IllegalArgumentException("invalid style");
636            
637      int oldStyle = windowDecorationStyle;      int oldStyle = windowDecorationStyle;

Legend:
Removed from v.1.12.2.7  
changed lines
  Added in v.1.12.2.8

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