|
Re: Making Composite to ScrolledComposite [message #905567 is a reply to message #905536] |
Thu, 30 August 2012 16:42 |
|
Hi Johann,
You have to set the content in the ScrolledComposite.
If you switch back to your composite....and then wrap that with a ScrolledCOmposite. Don't forget to call scrolledComposite.setContent(yourOriginalComposite)!
The javadoc contains a simple example. I would advise you to take a look at it.
In general there are plenty of code snippets, and javadocs available to help you - they are very complete.
Sharon
|
|
|
Re: Making Composite to ScrolledComposite [message #905947 is a reply to message #905567] |
Fri, 31 August 2012 11:01 |
Johann Vogel Messages: 20 Registered: February 2012 |
Junior Member |
|
|
Thank you Sharon
I have already read that, but just to method 1, which didn't work for me. I also tried method 2, but my fault was that I used scrollComp.setMinSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); before comp was "filled" and had the real size.
So, my solution was changing:
public void createPartControl(Composite parent) {
top = new Composite(parent, SWT.NONE);
top.setLayout(new GridLayout());
top.setFont(new Font(Display.getDefault(), "Tahoma", 10, SWT.NORMAL));
...
createHead(); //fill top
to
ScrolledComposite toptop = new ScrolledComposite(parent, SWT.H_SCROLL|SWT.BORDER); //this adds left-to-right scrolling, what is quite confusing, because i'd expect H_Scroll to add a scrollbar that scrolls horicontally
toptop.setExpandVertical(true);
toptop.setExpandHorizontal(true); //important: both, otherwise it didn't even get visible for me. even if i just h_Scroll
top = new Composite(toptop, SWT.NONE);
top.setLayout(new GridLayout());
top.setFont(new Font(Display.getDefault(), "Tahoma", 10, SWT.NORMAL));
toptop.setContent(top); //also important! otherwise empty
..
createHead(); //fill top
toptop.setMinSize(top.computeSize(SWT.DEFAULT, SWT.DEFAULT)); //make this AFTER fillig the Composite, otherwise it won't work!
|
|
|
Re: Making Composite to ScrolledComposite [message #905984 is a reply to message #905947] |
Fri, 31 August 2012 12:16 |
|
Yes, that is correct, you need to set minSize after it's been filled. I'm glad you figured it out and posted your solution.
Posting the code helps to understand just what your problem is. I know when I first used the ScrolledComposite I kept forgetting to setContent(), so I naturally assumed that was where you were having your problems.
|
|
|
Powered by
FUDForum. Page generated in 0.03121 seconds