classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Implemented createLayoutManager in javax.swing.JViewpo


From: Roman Kennke
Subject: [cp-patches] FYI: Implemented createLayoutManager in javax.swing.JViewport
Date: Mon, 23 May 2005 15:09:14 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

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

2005-05-23  Roman Kennke  <address@hidden>

       * 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);
   }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]