Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Annoying scrollbar problem
Annoying scrollbar problem [message #463568] Wed, 09 November 2005 10:30 Go to next message
Lars is currently offline LarsFriend
Messages: 32
Registered: July 2009
Member
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 #463570 is a reply to message #463568] Wed, 09 November 2005 12:31 Go to previous messageGo to next message
hortiz Mising name is currently offline hortiz Mising nameFriend
Messages: 96
Registered: July 2009
Member
Hi Lars,

Could you give all the code sample ? (notably the declaration of the
outerComp)
Re: Annoying scrollbar problem [message #463572 is a reply to message #463568] Wed, 09 November 2005 14:44 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
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 Go to previous message
Lars is currently offline LarsFriend
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();
>>
>
>
>
>
Previous Topic:Shift-Tab + Key Listeners
Next Topic:Cancel Button of a WizardPage
Goto Forum:
  


Current Time: Thu Apr 18 12:30:17 GMT 2024

Powered by FUDForum. Page generated in 0.01986 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top