|
|
Re: Annoying scrollbar problem [message #463572 is a reply to message #463568] |
Wed, 09 November 2005 14:44 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
You need to set the minimum size for the ScrolledComposite:
scrollableCom.setMinSize(innerComp.computeSize(SWT.DEFAULT,
SWT.DEFAULT));
You also need to do this every time the text size changes.
Note the following lines in your code below are not doing anything useful:
scrollableCom.setLayout(new FillLayout());
innerComp.setSize(innerComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Also, I am not sure why you have innerComp - you could just parent the Text
widget directly in scrollableCom.
See the following examples:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet5.java?rev=HEAD&am p;content-type=text/vnd.viewcvs-markup
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet166.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
Also, the javadoc for ScrolledComposite gives two examples of how to use the
API.
"Lars" <lars@eclub2.procard.dk> wrote in message
news:dksj4m$r0b$1@news.eclipse.org...
> Hi all
>
> How come the scrollbar composite below does not activate the scrollbars,
> when the text in textValue is to big to be displayed? It shows the
> scrollbars as expected, but they are not activated, even when text is is
> way too big to be displayed
>
> Hope you can help. It seems like I tried everything :-)
>
> */Lars
>
> --------------------------
>
> ScrollableCom = new ScrolledComposite(
> outerComp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
>
> scrollableCom.setLayout(new FillLayout());
>
> innerComp = new Composite(scrollableCom, SWT.NONE);
> scrollableCom.setContent(innerComp);
>
> innerComp.setLayout(new FillLayout());
> textValue = new Text(innerComp, SWT.WRAP | SWT.MULTI );
> textValue.setText(errorText);
>
> scrollableCom.setExpandHorizontal(true);
> scrollableCom.setExpandVertical(true);
>
> scrollableCom.setAlwaysShowScrollBars(true);
>
> innerComp.setSize(innerComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
> outerComp.layout();
>
|
|
|
Re: Annoying scrollbar problem [message #463644 is a reply to message #463572] |
Fri, 11 November 2005 13:04 |
Lars Messages: 32 Registered: July 2009 |
Member |
|
|
Hi Veronica
Thanks, it worked fine. It was just the missing link :-)
*/Lars
Veronika Irvine wrote:
>
> You need to set the minimum size for the ScrolledComposite:
>
> scrollableCom.setMinSize(innerComp.computeSize(SWT.DEFAULT,
> SWT.DEFAULT));
>
> You also need to do this every time the text size changes.
>
> Note the following lines in your code below are not doing anything useful:
>
> scrollableCom.setLayout(new FillLayout());
> innerComp.setSize(innerComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>
> Also, I am not sure why you have innerComp - you could just parent the Text
> widget directly in scrollableCom.
>
> See the following examples:
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet5.java?rev=HEAD&am p;content-type=text/vnd.viewcvs-markup
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet166.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
>
> Also, the javadoc for ScrolledComposite gives two examples of how to use the
> API.
>
> "Lars" <lars@eclub2.procard.dk> wrote in message
> news:dksj4m$r0b$1@news.eclipse.org...
>
>>Hi all
>>
>>How come the scrollbar composite below does not activate the scrollbars,
>>when the text in textValue is to big to be displayed? It shows the
>>scrollbars as expected, but they are not activated, even when text is is
>>way too big to be displayed
>>
>>Hope you can help. It seems like I tried everything :-)
>>
>>*/Lars
>>
>>--------------------------
>>
>>ScrollableCom = new ScrolledComposite(
>>outerComp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
>>
>>scrollableCom.setLayout(new FillLayout());
>>
>>innerComp = new Composite(scrollableCom, SWT.NONE);
>>scrollableCom.setContent(innerComp);
>>
>>innerComp.setLayout(new FillLayout());
>>textValue = new Text(innerComp, SWT.WRAP | SWT.MULTI );
>>textValue.setText(errorText);
>>
>>scrollableCom.setExpandHorizontal(true);
>>scrollableCom.setExpandVertical(true);
>>
>>scrollableCom.setAlwaysShowScrollBars(true);
>>
>>innerComp.setSize(innerComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
>>outerComp.layout();
>>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.01986 seconds