content
Control content
DrawableThere are two ways to use the ScrolledComposite:
public static void main (String [] args) {
Display display = new Display ();
Color red = display.getSystemColor(SWT.COLOR_RED);
Color blue = display.getSystemColor(SWT.COLOR_BLUE);
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
// set the size of the scrolled content - method 1
final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite c1 = new Composite(sc1, SWT.NONE);
sc1.setContent(c1);
c1.setBackground(red);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
c1.setLayout(layout);
Button b1 = new Button (c1, SWT.PUSH);
b1.setText("first button");
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
// set the minimum width and height of the scrolled content - method 2
final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
sc2.setExpandHorizontal(true);
sc2.setExpandVertical(true);
final Composite c2 = new Composite(sc2, SWT.NONE);
sc2.setContent(c2);
c2.setBackground(blue);
layout = new GridLayout();
layout.numColumns = 4;
c2.setLayout(layout);
Button b2 = new Button (c2, SWT.PUSH);
b2.setText("first button");
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Button add = new Button (shell, SWT.PUSH);
add.setText("add children");
final int[] index = new int[]{0};
add.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
index[0]++;
Button button = new Button(c1, SWT.PUSH);
button.setText("button "+index[0]);
// reset size of content so children can be seen - method 1
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c1.layout();
button = new Button(c2, SWT.PUSH);
button.setText("button "+index[0]);
// reset the minimum width and height so children can be seen - method 2
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c2.layout();
}
});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
(package private) boolean(package private) Control(package private) Listener(package private) boolean(package private) boolean(package private) Listener(package private) int(package private) int(package private) boolean(package private) booleanembeddedHandleScrolledComposite(Composite parent,
int style) (package private) static intcheckStyle(int style) (package private) booleanbooleanbooleantrue if the content control
will be expanded to fill available horizontal space.booleantrue if the content control
will be expanded to fill available vertical space.intintbooleantrue if the receiver automatically scrolls to a focused child control
to make it visible.(package private) voidhScroll()(package private) booleanneedHScroll(Rectangle contentRect,
boolean vVisible) (package private) booleanneedVScroll(Rectangle contentRect,
boolean hVisible) voidsetAlwaysShowScrollBars(boolean show) voidsetContent(Control content) voidsetExpandHorizontal(boolean expand) voidsetExpandVertical(boolean expand) voidvoidsetMinHeight(int height) voidsetMinSize(int width,
int height) voidsetMinSize(Point size) voidsetMinWidth(int width) voidsetOrigin(int x,
int y) voidvoidsetShowFocusedControl(boolean show) voidshowControl(Control control) (package private) voidvScroll()changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabList, toStringcomputeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsModeaddControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateaddDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setData
The style value is either one of the style constants defined in
class SWT which is applicable to instances of this
class, or must be built by bitwise OR'ing together
(that is, using the int "|" operator) two or more
of those SWT style constants. The class description
lists the style constants that are applicable to the class.
Style bits are also inherited from superclasses.
parent - a widget which will be the parent of the new instance (cannot be null)style - the style of widget to constructIllegalArgumentException - SWTException - true if the content control
will be expanded to fill available horizontal space.SWTException - true if the content control
will be expanded to fill available vertical space.SWTException - SWTException - SWTException - true if the receiver automatically scrolls to a focused child control
to make it visible. Otherwise, returns false.SWTException - SWTException - origin - the point on the content to appear in the top left cornerSWTException - x - the x coordinate of the content to appear in the top left cornery - the y coordinate of the content to appear in the top left cornerSWTException - show - true to show the scrollbars even when not required, false to show scrollbars only when requiredSWTException - content - the control to be displayed in the content areaSWTException - expand - true to expand the content control to fill available horizontal spaceSWTException - expand - true to expand the content control to fill available vertical spaceSWTException - Note: No Layout can be set on this Control because it already manages the size and position of its children.
setLayout in class Compositelayout - the receiver's new layout or nullSWTException - height - the minimum height or 0 for default heightSWTException - size - the minimum size or null for the default sizeSWTException - width - the minimum width or 0 for default widthheight - the minimum height or 0 for default heightSWTException - width - the minimum width or 0 for default widthSWTException - false, show a focused control is off.
By default, show a focused control is off.show - true to show a focused control.SWTException - control - the control to be shownIllegalArgumentException - SWTException -