Permalink
Browse files

Added some explanations to ScrollPane and Viewport to more clearly

document the usage of the "view" property to add the children.

This a merge of revision 1458918 from branches/2.0.x to trunk.


git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1458921 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent d8df74b commit 882799e0d83d99d8964a28c6e1f16b7769627989 Roger Lee Whitcomb committed Mar 20, 2013
Showing with 23 additions and 0 deletions.
  1. +4 −0 wtk/src/org/apache/pivot/wtk/ScrollPane.java
  2. +19 −0 wtk/src/org/apache/pivot/wtk/Viewport.java
@@ -22,6 +22,10 @@
/**
* Container that provides a scrollable view of a component, with optional
* fixed row and column headers.
+ * <p> The single component to be scrolled will typically be a {@link Container}
+ * and should be specified by the {@link #setView setView()} method (the "view" property).
+ * So, even then though this class is a {@link Container}, you should not add
+ * components to it via the {@link #add add()} method.
*/
public class ScrollPane extends Viewport {
/**
@@ -24,6 +24,10 @@
* Abstract base class for viewport components. Viewports provide a windowed
* view on a component (called the "view") that is too large to fit within a
* given area. They are generally scrollable.
+ * <p> Even though this class is a {@link Container}, no components should be
+ * added to it via the {@link #add add()} method. The component that gets the
+ * windowed (or scrollable) view should be added via the {@link #setView setView()}
+ * method (or the "view" property).
*/
@DefaultProperty("view")
public abstract class Viewport extends Container {
@@ -107,10 +111,18 @@ public void setScrollLeft(int scrollLeft) {
}
}
+ /**
+ * Returns the (single) component (typically a {@link Container})
+ * that we are providing a windowed (or scrollable) view of.
+ */
public Component getView() {
return view;
}
+ /**
+ * Set the single component (typically a {@link Container}) that
+ * we will provide a windowed (or scrollable) view of.
+ */
public void setView(Component view) {
Component previousView = this.view;
@@ -176,6 +188,13 @@ public void repaint(int x, int y, int width, int height, boolean immediate) {
}
}
+ /**
+ * This method should not be called to remove child components
+ * from the Viewport because the viewable child(ren) are set
+ * by the {@link #setView} method instead. Any attempt to
+ * remove the "view" component with this method will result
+ * in an exception.
+ */
@Override
public Sequence<Component> remove(int index, int count) {
for (int i = index, n = index + count; i < n; i++) {

0 comments on commit 882799e

Please sign in to comment.