Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2001-09-12 12:49:14 +0000
committerVeronika Irvine2001-09-12 12:49:14 +0000
commit10e4a8636f840265f9d8a55a03f1f6b85117b9df (patch)
treecc35db4a9ac72abcf8826dadb4e55b8d029f0554 /bundles
parent931e0fa35f865deecdf72b3318c7b158be61612b (diff)
downloadeclipse.platform.swt-10e4a8636f840265f9d8a55a03f1f6b85117b9df.tar.gz
eclipse.platform.swt-10e4a8636f840265f9d8a55a03f1f6b85117b9df.tar.xz
eclipse.platform.swt-10e4a8636f840265f9d8a55a03f1f6b85117b9df.zip
*** empty log message ***
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java75
1 files changed, 69 insertions, 6 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
index daadb8facb..164ba0468c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
@@ -9,17 +9,80 @@ import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
-/*
+/**
* A ScrolledComposite provides scrollbars and will scroll its content when the user
* uses the scrollbars.
*
- * <p>If the ScrolledComposite can be configured to stretch the content to be as big as the
- * ScrolledComposite when the composite is resized to a size larger than the minimum width
- * or minimum height and to provide scrolls when the ScrolledComposite is smaller than the
- * minimum width and minimum height. Refer to the methods setExpandHorizontal,
- * setExpandVertical, setMinWidth and setMinHeight.
*
+ * <p>There are two ways to use the ScrolledComposite:
+ *
* <p>
+ * 1) Set the size of the control that is being scrolled and the ScrolledComposite
+ * will show scrollbars when the contained control can not be fully seen.
+ *
+ * <code><pre>
+ * public static void main (String [] args) {
+ * Display display = new Display ();
+ * Color red = display.getSystemColor(SWT.COLOR_RED);
+ * Shell shell = new Shell (display);
+ * shell.setLayout(new FillLayout());
+ * ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
+ * Composite c = new Composite(sc, SWT.NONE);
+ * c.setBackground(red);
+ * sc.setContent(c);
+ * GridLayout layout = new GridLayout();
+ * layout.numColumns = 5;
+ * c.setLayout(layout);
+ * for (int i = 0; i < 10; i++) {
+ * Button b1 = new Button(c, SWT.PUSH);
+ * b1.setText("button "+i);
+ * }
+ * Point pt = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ * c.setSize(pt);
+ * shell.open ();
+ * while (!shell.isDisposed ()) {
+ * if (!display.readAndDispatch ()) display.sleep ();
+ * }
+ * display.dispose ();
+ * }
+ * </pre></code>
+ *
+ * 2) The second way imitates the way a browser would work. Set the minimum size of
+ * the control and the ScrolledComposite will show scroll bars if the visible area is
+ * less than the minimum size of the control and it will expand the size of the control
+ * if the visible area is greater than the minimum size. This requires invoking
+ * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical().
+ *
+ * <code><pre>
+ * public static void main (String [] args) {
+ * Display display = new Display ();
+ * Color red = display.getSystemColor(SWT.COLOR_RED);
+ * Shell shell = new Shell (display);
+ * shell.setLayout(new FillLayout());
+ * ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
+ * Composite c = new Composite(sc, SWT.NONE);
+ * c.setBackground(red);
+ * sc.setContent(c);
+ * GridLayout layout = new GridLayout();
+ * layout.numColumns = 5;
+ * c.setLayout(layout);
+ * for (int i = 0; i < 10; i++) {
+ * Button b1 = new Button(c, SWT.PUSH);
+ * b1.setText("button "+i);
+ * }
+ * Point pt = c.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ * sc.setExpandHorizontal(true);
+ * sc.setExpandVertical(true);
+ * sc.setMinWidth(pt.x);
+ * sc.setMinHeight(pt.y);
+ * shell.open ();
+ * while (!shell.isDisposed ()) {
+ * if (!display.readAndDispatch ()) display.sleep ();
+ * }
+ * display.dispose ();
+ * }
+ * </pre></code>
+ *
* <dl>
* <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
* </dl>

Back to the top