Making Composite to ScrolledComposite [message #905536] |
Thu, 30 August 2012 11:27  |
Eclipse User |
|
|
|
I have to patch an eclipse-swt-application. To be concrete I simply have to wrap a composite inside of an editor (EditorPart) with a scrollbar. The first try was to set the V_-Scroll layout-argument, what gives me scrollbars that don't work, but then i tried to simply replace the Composite with ScrolledComposite (keeping V_scroll), and the whole content disappered (same as using composite with setVisible(false) ). The layout of the containing element is a grid-layout, if this is relevant.
What do I have to change, that my content will be visible again?
Sorry if I didn't provide information, I am quite new to SWT.
|
|
|
|
Re: Making Composite to ScrolledComposite [message #905947 is a reply to message #905567] |
Fri, 31 August 2012 07:01   |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.23279 seconds