summaryrefslogtreecommitdiff
path: root/java/awt/ScrollPane.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-10 19:35:37 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-10 19:35:37 +0000
commitf4b2de8ebb01a1e4a906682edaa17785fff813c9 (patch)
treecaae0a89736a380f7879b2181ad999725ac83f5b /java/awt/ScrollPane.java
parentd1b6fb1ce48424b1eb608f8432a758627a3ba25d (diff)
downloadclasspath-generics-stoppoint.tar.gz
2006-12-10 Andrew John Hughes <gnu_andrew@member.fsf.org>generics-stoppoint
* Merge of HEAD-->generics-branch for classpath-0.93-branch-point to generics-mergepoint
Diffstat (limited to 'java/awt/ScrollPane.java')
-rw-r--r--java/awt/ScrollPane.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java
index 35a81300d..ec9746f93 100644
--- a/java/awt/ScrollPane.java
+++ b/java/awt/ScrollPane.java
@@ -338,10 +338,15 @@ getVScrollbarWidth()
* Returns the current scroll position of the viewport.
*
* @return The current scroll position of the viewport.
+ *
+ * @throws NullPointerException if the scrollpane does have a child.
*/
public Point
getScrollPosition()
{
+ if (getComponentCount() == 0)
+ throw new NullPointerException();
+
int x = 0;
int y = 0;
@@ -380,20 +385,35 @@ setScrollPosition(Point scrollPosition) throws IllegalArgumentException
* @param x The new X coordinate of the scroll position.
* @param y The new Y coordinate of the scroll position.
*
+ * @throws NullPointerException if scrollpane does not have a child.
+ *
* @exception IllegalArgumentException If the specified value is outside
* the legal scrolling range.
*/
public void
setScrollPosition(int x, int y)
{
+ if (getComponentCount() == 0)
+ throw new NullPointerException("child is null");
+
+ if (x > (int) (getComponent(0).getWidth() - getViewportSize().getWidth()))
+ x = (int) (getComponent(0).getWidth() - getViewportSize().getWidth());
+ if (y > (int) (getComponent(0).getHeight() - getViewportSize().getHeight()))
+ y = (int) (getComponent(0).getHeight() - getViewportSize().getHeight());
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
Adjustable h = getHAdjustable();
Adjustable v = getVAdjustable();
-
+
if (h != null)
h.setValue(x);
if (v != null)
v.setValue(y);
-
+
ScrollPanePeer spp = (ScrollPanePeer)getPeer();
if (spp != null)
spp.setScrollPosition(x, y);
@@ -505,6 +525,8 @@ layout()
p.y = dim.height;
setScrollPosition (p);
+
+ list[0].setLocation(new Point());
}
}