diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
commit | 97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/java/awt/ScrollPane.java | |
parent | c648dedbde727ca3f883bb5fd773aa4af70d3369 (diff) | |
download | gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.zip gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.gz gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.bz2 |
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
Diffstat (limited to 'libjava/classpath/java/awt/ScrollPane.java')
-rw-r--r-- | libjava/classpath/java/awt/ScrollPane.java | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/libjava/classpath/java/awt/ScrollPane.java b/libjava/classpath/java/awt/ScrollPane.java index 65ce484..ec9746f 100644 --- a/libjava/classpath/java/awt/ScrollPane.java +++ b/libjava/classpath/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); @@ -414,7 +434,7 @@ addNotify() super.addNotify(); Component[] list = getComponents(); - if (list != null && list.length > 0 && ! (list[0] instanceof Panel)) + if (list != null && list.length > 0 && list[0].isLightweight()) { Panel panel = new Panel(); panel.setLayout(new BorderLayout()); @@ -453,9 +473,7 @@ removeNotify() if ((list != null) && (list.length > 0)) remove(list[0]); - super.addImpl(component, constraints, -1); - - doLayout(); + super.addImpl(component, constraints, index); } /*************************************************************************/ @@ -507,6 +525,8 @@ layout() p.y = dim.height; setScrollPosition (p); + + list[0].setLocation(new Point()); } } @@ -518,11 +538,12 @@ layout() * not have layout managers. * * @param layoutManager Ignored + * @throws AWTError Always throws this error when called. */ public final void setLayout(LayoutManager layoutManager) { - return; + throw new AWTError("ScrollPane controls layout"); } /*************************************************************************/ @@ -553,16 +574,37 @@ paramString() + getX() + "," + getY() + "," + getWidth() + "x" + getHeight() + "," - + "ScrollPosition=(" + scrollPosition.getX() + "," - + scrollPosition.getY() + ")," + + getIsValidString() + "," + + "ScrollPosition=(" + scrollPosition.x + "," + + scrollPosition.y + ")," + "Insets=(" + insets.top + "," + insets.left + "," + insets.bottom + "," + insets.right + ")," - + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + "," + + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicyString() + "," + "wheelScrollingEnabled=" + isWheelScrollingEnabled(); } +private String +getScrollbarDisplayPolicyString() +{ + if (getScrollbarDisplayPolicy() == 0) + return "as-needed"; + else if (getScrollbarDisplayPolicy() == 1) + return "always"; + else + return "never"; +} + +private String +getIsValidString() +{ + if (isValid()) + return "valid"; + else + return "invalid"; +} + /** * Tells whether or not an event is enabled. * |