Adding Scrollbars to a Window [message #686565] |
Wed, 22 June 2011 14:01 |
ouri.maler Messages: 22 Registered: July 2010 |
Junior Member |
|
|
I'm working on a GUI that consists of a multi-tabbed window, with each tab having its Buttons, Text consoles and the such.
Now, under certain circumstances, the window is going to be too large to fit into the screen. Because of that, I wanted to make it so that one could scroll horizontally and vertically through it (something I had no problem doing earlier with the Text consoles).
As it stands, the relevant code goes like this:
public void init(){
...
final Shell shell = new Shell(display);
...
final TabFolder tabFolder = new TabFolder (shell, SWT.V_SCROLL | SWT.H_SCROL);
TabItem controls = new TabItem (tabFolder, SWT.NONE);
TabItem graphView = new TabItem (tabFolder, SWT.NONE);
TabItem refinement = new TabItem (tabFolder, SWT.NONE);
...
Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayout(lineLayout);
controls.setControl(composite);
Composite buttons = new Composite(composite, SWT.NONE);
mainConsole = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
....
No matter how much I resize, though, the shell window still doesn't have any scrollbars (though the mainConsole Text within it does). What mistake am I making here?
|
|
|
|
Re: Adding Scrollbars to a Window [message #687938 is a reply to message #687776] |
Thu, 23 June 2011 14:51 |
ouri.maler Messages: 22 Registered: July 2010 |
Junior Member |
|
|
Following your advice, I tried the following approach:
public void init(){
...
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
...
final ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.H_SCROLL |SWT.V_SCROLL);
scrolledComposite.setLayout(new FillLayout());
final TabFolder tabFolder = new TabFolder (scrolledComposite, SWT.BORDER);
TabItem controls = new TabItem (tabFolder, SWT.NONE);
TabItem graphView = new TabItem (tabFolder, SWT.NONE);
TabItem refinement = new TabItem (tabFolder, SWT.NONE);
...
Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayout(lineLayout);
controls.setControl(composite);
Composite buttons = new Composite(composite, SWT.NONE);
mainConsole = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
....
Unfortunately, this only seems to aggravate the situation - not only do scrollbars still not appear, but now the window is also very small when I launch the program (though it can be resized manually).
I've looked at the snippets and tried a few variations (such as declaring or not declaring a Layout for the ScrolledComposite), but I can't seem to find the cause...
|
|
|
|
Powered by
FUDForum. Page generated in 0.03266 seconds