[Patch] javax.swing.JRootPane

Michael Koch konqueror@gmx.de
Tue Apr 19 06:25:00 GMT 2005


Hi list,


I just commited the attached patch to merge javax.swing.JRootPane and
javax.swing.plaf.basic.BasicMenuUI from GNU classpath to HEAD.


Michael


2005-04-19  Roman Kennke  <roman@kennke.org>

	* javax/swing/plaf/basic/BasicMenuUI.java
	(getMaximumSize): Now returns preferredSize because JMenu should
	never be bigger than that.
	* javax/swing/JRootPane
	(RootLayout.layoutContainer): Make JMenuBars take the whole width.

2005-04-19  Roman Kennke  <roman@kennke.org>

	* javax/swing/JRootPane.java:
	Fixed various tabs to be spaces.
	(RootLayout.layoutContainer): Made menubar left aligned.

-------------- next part --------------
Index: javax/swing/JRootPane.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JRootPane.java,v
retrieving revision 1.10
diff -u -r1.10 JRootPane.java
--- javax/swing/JRootPane.java	16 Feb 2005 20:02:33 -0000	1.10
+++ javax/swing/JRootPane.java	19 Apr 2005 06:21:50 -0000
@@ -189,52 +189,52 @@
       */
       if (containerSize.width == 0 && containerSize.height == 0)
         {
-	  if (menuBar != null)
-	    {
-	      int maxWidth;
-	      menuBarSize = menuBar.getPreferredSize();
-	      maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
-	      menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
-	      glassPane.setBounds(0, menuBarSize.height, maxWidth,
-	                          contentPaneSize.height);
-	      contentPane.setBounds(0, menuBarSize.height, maxWidth,
-	                            contentPaneSize.height);
-	      layeredPane.setSize(maxWidth,
-	                          menuBarSize.height + contentPaneSize.height);
-	    }
-	  else
-	    {
-	      glassPane.setBounds(0, 0, contentPaneSize.width,
-	                          contentPaneSize.height);
-	      contentPane.setBounds(0, 0, contentPaneSize.width,
-	                            contentPaneSize.height);
-	      layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
-	    }
+          if (menuBar != null)
+            {
+              int maxWidth;
+              menuBarSize = menuBar.getPreferredSize();
+              maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
+              menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
+              glassPane.setBounds(0, menuBarSize.height, maxWidth,
+                                  contentPaneSize.height);
+              contentPane.setBounds(0, menuBarSize.height, maxWidth,
+                                    contentPaneSize.height);
+              layeredPane.setSize(maxWidth,
+                                  menuBarSize.height + contentPaneSize.height);
+            }
+          else
+            {
+              glassPane.setBounds(0, 0, contentPaneSize.width,
+                                  contentPaneSize.height);
+              contentPane.setBounds(0, 0, contentPaneSize.width,
+                                    contentPaneSize.height);
+              layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
+            }
         }
       else
         {
-	  if (menuBar != null)
-	    {
-	      menuBarSize = menuBar.getPreferredSize();
-	      if (menuBarSize.height > containerSize.height)
-		menuBarSize.height = containerSize.height;
-	      menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
-	      int remainingHeight = containerSize.height - menuBarSize.height;
-	      glassPane.setBounds(0, menuBarSize.height, containerSize.width,
-	                          containerSize.height - menuBarSize.height);
-	      contentPane.setBounds(0, menuBarSize.height,
-	                            containerSize.width,
-	                            (containerSize.height - menuBarSize.height));
-	    }
-	  else
-	    {
-	      glassPane.setBounds(0, 0, containerSize.width,
-	                          containerSize.height);
-	      contentPane.setBounds(0, 0, containerSize.width,
-	                            containerSize.height);
-	    }
+          if (menuBar != null)
+            {
+              menuBarSize = menuBar.getPreferredSize();
+              if (menuBarSize.height > containerSize.height)
+                menuBarSize.height = containerSize.height;
+              menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
+              int remainingHeight = containerSize.height - menuBarSize.height;
+              glassPane.setBounds(0, menuBarSize.height, containerSize.width,
+                                  containerSize.height - menuBarSize.height);
+              contentPane.setBounds(0, menuBarSize.height,
+                                    containerSize.width,
+                                    (containerSize.height - menuBarSize.height));
+            }
+          else
+            {
+              glassPane.setBounds(0, 0, containerSize.width,
+                                  containerSize.height);
+              contentPane.setBounds(0, 0, containerSize.width,
+                                    containerSize.height);
+            }
 
-	  layeredPane.setSize(containerSize.width, containerSize.height);
+          layeredPane.setSize(containerSize.width, containerSize.height);
         }
     }
 
@@ -279,20 +279,20 @@
 
       if (containerSize.width == 0 && containerSize.height == 0)
         {
-	  if (menuBar != null)
-	    {
-	      int maxWidth;
-	      menuBarSize = menuBar.getPreferredSize();
-	      maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
-	      prefSize = new Dimension(maxWidth,
-	                               contentPaneSize.height
-	                               + menuBarSize.height);
-	    }
-	  else
-	    prefSize = contentPaneSize;
+          if (menuBar != null)
+            {
+              int maxWidth;
+              menuBarSize = menuBar.getPreferredSize();
+              maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
+              prefSize = new Dimension(maxWidth,
+                                       contentPaneSize.height
+                                       + menuBarSize.height);
+            }
+          else
+            prefSize = contentPaneSize;
         }
       else
-	prefSize = c.getSize();
+        prefSize = c.getSize();
 
       return prefSize;
     }
@@ -319,7 +319,7 @@
   public static final int FILE_CHOOSER_DIALOG = 6;
   public static final int QUESTION_DIALOG = 7;
   public static final int WARNING_DIALOG = 8;
-	  
+          
   /** DOCUMENT ME! */
   protected Component glassPane;
 
@@ -609,13 +609,13 @@
   public void setWindowDecorationStyle(int style)
   {
     if (style != NONE
-	&& style != FRAME
-	&& style != INFORMATION_DIALOG
-	&& style != ERROR_DIALOG
-	&& style != COLOR_CHOOSER_DIALOG
-	&& style != FILE_CHOOSER_DIALOG
-	&& style != QUESTION_DIALOG
-	&& style != WARNING_DIALOG)
+        && style != FRAME
+        && style != INFORMATION_DIALOG
+        && style != ERROR_DIALOG
+        && style != COLOR_CHOOSER_DIALOG
+        && style != FILE_CHOOSER_DIALOG
+        && style != QUESTION_DIALOG
+        && style != WARNING_DIALOG)
       throw new IllegalArgumentException("invalid style");
     
     int oldStyle = windowDecorationStyle;
Index: javax/swing/plaf/basic/BasicMenuUI.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/plaf/basic/BasicMenuUI.java,v
retrieving revision 1.9
diff -u -r1.9 BasicMenuUI.java
--- javax/swing/plaf/basic/BasicMenuUI.java	16 Feb 2005 20:02:54 -0000	1.9
+++ javax/swing/plaf/basic/BasicMenuUI.java	19 Apr 2005 06:21:50 -0000
@@ -179,7 +179,7 @@
    */
   public Dimension getMaximumSize(JComponent c)
   {
-    return null;
+    return c.getPreferredSize();
   }
 
   protected String getPropertyPrefix()


More information about the Java-patches mailing list