This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui] [PATCH] ScrollPane fixes
- From: David Jee <djee at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 06 Jul 2004 11:00:05 -0400
- Subject: [gui] [PATCH] ScrollPane fixes
Hello,
I committed the following patch to the java-gui-branch. It fixes
ScrollPane so that when you add a non-Panel component to a ScrollPane,
it will automatically get wrapped with a new Panel. Also, the patch
sets the default size of a ScrollPane to 100x100, as the API dictates.
There are other small fixes: ScrollPane.paramString() is implemented to
give more helpful information, and an unnecessary call to validate() is
removed from GtkContainerPeer.setBounds().
-David Jee
2004-07-06 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(setBounds): Do not validate awtComponent here.
* gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
(getPreferredSize): New method.
* java/awt/ScrollPane.java
(ScrollPane): Set default size to 100x100.
(addNotify): If child is not a Panel, wrap it with a new Panel.
(paramString): Implement.
Index: gnu/java/awt/peer/gtk/GtkContainerPeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 GtkContainerPeer.java
--- gnu/java/awt/peer/gtk/GtkContainerPeer.java 27 May 2004 18:12:14 -0000 1.8.2.3
+++ gnu/java/awt/peer/gtk/GtkContainerPeer.java 6 Jul 2004 14:49:54 -0000
@@ -90,7 +90,6 @@
public void setBounds (int x, int y, int width, int height)
{
super.setBounds (x, y, width, height);
- awtComponent.validate ();
}
public void setFont(Font f)
Index: gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkScrollPanePeer.java,v
retrieving revision 1.3
diff -u -r1.3 GtkScrollPanePeer.java
--- gnu/java/awt/peer/gtk/GtkScrollPanePeer.java 5 Jan 2004 21:35:32 -0000 1.3
+++ gnu/java/awt/peer/gtk/GtkScrollPanePeer.java 6 Jul 2004 14:49:54 -0000
@@ -39,6 +39,7 @@
package gnu.java.awt.peer.gtk;
import java.awt.Adjustable;
+import java.awt.Dimension;
import java.awt.ScrollPane;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ScrollPanePeer;
@@ -87,10 +88,10 @@
native public int getVScrollbarWidth ();
native public void setScrollPosition (int x, int y);
-// public Dimension getPreferredSize ()
-// {
-// return new Dimension (60, 60);
-// }
+ public Dimension getPreferredSize ()
+ {
+ return awtComponent.getSize();
+ }
public void setUnitIncrement (Adjustable adj, int u)
{
Index: java/awt/ScrollPane.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/ScrollPane.java,v
retrieving revision 1.15
diff -u -r1.15 ScrollPane.java
--- java/awt/ScrollPane.java 3 Feb 2004 17:10:54 -0000 1.15
+++ java/awt/ScrollPane.java 6 Jul 2004 14:49:54 -0000
@@ -157,6 +157,9 @@
}
wheelScrollingEnabled = true;
+
+ // Default size.
+ setSize(100,100);
}
/*************************************************************************/
@@ -400,6 +403,15 @@
setPeer((ComponentPeer)getToolkit().createScrollPane(this));
super.addNotify();
+
+ Component[] list = getComponents();
+ if (list != null && list.length > 0 && ! (list[0] instanceof Panel))
+ {
+ Panel panel = new Panel();
+ panel.setLayout(new BorderLayout());
+ panel.add(list[0], BorderLayout.CENTER);
+ add(panel);
+ }
}
/*************************************************************************/
@@ -527,7 +539,19 @@
public String
paramString()
{
- return(getClass().getName());
+ Insets insets = getInsets();
+ return getName() + ","
+ + getX() + ","
+ + getY() + ","
+ + getWidth() + "x" + getHeight() + ","
+ + "ScrollPosition=(" + scrollPosition.getX() + ","
+ + scrollPosition.getY() + "),"
+ + "Insets=(" + insets.top + ","
+ + insets.left + ","
+ + insets.bottom + ","
+ + insets.right + "),"
+ + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + ","
+ + "wheelScrollingEnabled=" + isWheelScrollingEnabled();
}
/**