I added the method createLayoutManager to javax.swing.JViewport.

2005-05-23  Roman Kennke  <[EMAIL PROTECTED]>

       * javax/swing/JViewport.java
       (createLayoutManager): Added and implemented new method.
       (constructor): Set the LayoutManager that is created by
       createLayoutManager().
       * javax/swing/plaf/basic/BasicViewportUI.java
       (installUI): Removed setLayout(..). This is moved into
       the constructor of JViewport (as the API docs suggest).

/Roman

Index: javax/swing/JViewport.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JViewport.java,v
retrieving revision 1.18
diff -u -r1.18 JViewport.java
--- javax/swing/JViewport.java  23 May 2005 12:51:50 -0000      1.18
+++ javax/swing/JViewport.java  23 May 2005 13:03:46 -0000
@@ -42,6 +42,7 @@
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Insets;
+import java.awt.LayoutManager;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.event.ComponentAdapter;
@@ -190,6 +191,7 @@
   {
     setOpaque(true);
     setScrollMode(BLIT_SCROLL_MODE);
+    setLayout(createLayoutManager());
     updateUI();
   }
 
@@ -472,4 +474,15 @@
   {
     return new ViewListener();
   }
+
+  /**
+   * Creates the LayoutManager that is used for this viewport. Override
+   * this method if you want to use a custom LayoutManager.
+   *
+   * @return a LayoutManager to use for this viewport
+   */
+  protected LayoutManager createLayoutManager()
+  {
+    return new ViewportLayout();
+  }
 }
Index: javax/swing/plaf/basic/BasicViewportUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicViewportUI.java,v
retrieving revision 1.12
diff -u -r1.12 BasicViewportUI.java
--- javax/swing/plaf/basic/BasicViewportUI.java 11 Nov 2004 22:36:46 -0000      
1.12
+++ javax/swing/plaf/basic/BasicViewportUI.java 23 May 2005 13:03:46 -0000
@@ -103,7 +103,6 @@
   public void installUI(JComponent c) 
   {
     super.installUI(c);
-    c.setLayout(new ViewportLayout());
     installListeners(c);
   }
 
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to