Reputation: 2433
Using a tab window and giving the shell a fixed size, how can I make the content - meaning the whole shell - scrollable, if there's not enough space? Is this a setting of the shell, the tab host or the individual tabs?
Upvotes: 0
Views: 889
Reputation: 36894
Use a ScrolledComposite
which contains you whole content. This way it will scroll if there is not enough room to display it.
The following code should give you an idea on how it works:
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
// Create the ScrolledComposite to scroll horizontally and vertically
ScrolledComposite scrolledComp = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
// Create a child composite for your content
Composite content = new Composite(scrolledComp, SWT.NONE);
content.setLayout(new FillLayout());
// Create some content
new Button(content, SWT.PUSH).setText("Button1");
new Button(content, SWT.PUSH).setText("Button2");
// add content to scrolled composite
scrolledComp.setContent(content);
// Set the minimum size (in this case way too large)
scrolledComp.setMinSize(400, 400);
// Expand both horizontally and vertically
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
Run it, decrease the window size and you will see the scroll bars.
Upvotes: 2