Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Problem with ScrolledComposite
Problem with ScrolledComposite [message #116927] Mon, 22 December 2008 13:04 Go to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Hi,

I have a problem with ScrolledComposite.

When I start this little Snippet the Labels were cut off at the end.
But when I reload the page, everything will displayed fine.
Very strange!!!

And another problem is that I can't get it working that the Labels were
displayed centered.

Can anybody help me with this???

Roland





public class Test implements IEntryPoint {

public int createUI() {
Display display = PlatformUI.createDisplay();
Shell shell = new Shell( display );
shell.setBounds( 100, 100, 200, 200 );
shell.setLayout( new GridLayout() );

ScrolledComposite scroll = new ScrolledComposite( shell, SWT.V_SCROLL );
scroll.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
scroll.setLayout( new GridLayout() );

Composite composite = new Composite( scroll, SWT.NONE );
composite.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true,
true ) );
GridLayout gridLayout_1 = new GridLayout();
gridLayout_1.verticalSpacing = 150;
composite.setLayout( gridLayout_1 );

scroll.setContent( composite );

Label label = new Label( composite, SWT.NONE );
label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true, false
) );
label.setText( "Label" );

label = new Label( composite, SWT.NONE );
label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true, false
) );
label.setText( "Label" );

label = new Label( composite, SWT.NONE );
label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER, true, false
) );
label.setText( "Label" );

composite.pack();

shell.open();

while ( !shell.isDisposed() ) {
if ( !display.readAndDispatch() ) {
display.sleep();
}
}
return 0;
}
}
Re: Problem with ScrolledComposite [message #117043 is a reply to message #116927] Tue, 23 December 2008 11:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ifurnadjiev.innoopract.com

Hi Roland,

see my answers bellow...

Roland Siebert wrote:
> Hi,
>
> I have a problem with ScrolledComposite.
>
> When I start this little Snippet the Labels were cut off at the end.
> But when I reload the page, everything will displayed fine.
> Very strange!!!
I can't reproduce it with CVS HEAD. Which version of RAP do you use?
Which browser?
>
> And another problem is that I can't get it working that the Labels
> were displayed centered.
You just need to call scroll.setExpandHorizontal( true ); to instruct
ScrolledComposite to resize the content object to be as wide as the
ScrolledComposite itself.
>
> Can anybody help me with this???
>
> Roland

Best,
Ivan
>
>
>
>
>
> public class Test implements IEntryPoint {
>
> public int createUI() {
> Display display = PlatformUI.createDisplay();
> Shell shell = new Shell( display );
> shell.setBounds( 100, 100, 200, 200 );
> shell.setLayout( new GridLayout() );
>
> ScrolledComposite scroll = new ScrolledComposite( shell,
> SWT.V_SCROLL );
> scroll.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true,
> true ) );
> scroll.setLayout( new GridLayout() );
>
> Composite composite = new Composite( scroll, SWT.NONE );
> composite.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
> true, true ) );
> GridLayout gridLayout_1 = new GridLayout();
> gridLayout_1.verticalSpacing = 150;
> composite.setLayout( gridLayout_1 );
>
> scroll.setContent( composite );
>
> Label label = new Label( composite, SWT.NONE );
> label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
> true, false ) );
> label.setText( "Label" );
>
> label = new Label( composite, SWT.NONE );
> label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
> true, false ) );
> label.setText( "Label" );
>
> label = new Label( composite, SWT.NONE );
> label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
> true, false ) );
> label.setText( "Label" );
>
> composite.pack();
>
> shell.open();
>
> while ( !shell.isDisposed() ) {
> if ( !display.readAndDispatch() ) {
> display.sleep();
> }
> }
> return 0;
> }
> }
Re: Problem with ScrolledComposite [message #117161 is a reply to message #117043] Wed, 24 December 2008 13:12 Go to previous message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Hi,

i found a solution.

After filling the compsite i call "scrolledComposite.setMinSize(
composite.computeSize( SWT.DEFAULT, SWT.DEFAULT ) );"

And for the center-problem it is working with
"scrolledComposite.setExpandHorizontal( true );"

Thanks.
Roland


Ivan Furnadjiev schrieb:
> Hi Roland,
>
> see my answers bellow...
>
> Roland Siebert wrote:
>> Hi,
>>
>> I have a problem with ScrolledComposite.
>>
>> When I start this little Snippet the Labels were cut off at the end.
>> But when I reload the page, everything will displayed fine.
>> Very strange!!!
> I can't reproduce it with CVS HEAD. Which version of RAP do you use?
> Which browser?
>>
>> And another problem is that I can't get it working that the Labels
>> were displayed centered.
> You just need to call scroll.setExpandHorizontal( true ); to instruct
> ScrolledComposite to resize the content object to be as wide as the
> ScrolledComposite itself.
>>
>> Can anybody help me with this???
>>
>> Roland
>
> Best,
> Ivan
>>
>>
>>
>>
>>
>> public class Test implements IEntryPoint {
>>
>> public int createUI() {
>> Display display = PlatformUI.createDisplay();
>> Shell shell = new Shell( display );
>> shell.setBounds( 100, 100, 200, 200 );
>> shell.setLayout( new GridLayout() );
>>
>> ScrolledComposite scroll = new ScrolledComposite( shell,
>> SWT.V_SCROLL );
>> scroll.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true,
>> true ) );
>> scroll.setLayout( new GridLayout() );
>>
>> Composite composite = new Composite( scroll, SWT.NONE );
>> composite.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
>> true, true ) );
>> GridLayout gridLayout_1 = new GridLayout();
>> gridLayout_1.verticalSpacing = 150;
>> composite.setLayout( gridLayout_1 );
>>
>> scroll.setContent( composite );
>>
>> Label label = new Label( composite, SWT.NONE );
>> label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
>> true, false ) );
>> label.setText( "Label" );
>>
>> label = new Label( composite, SWT.NONE );
>> label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
>> true, false ) );
>> label.setText( "Label" );
>>
>> label = new Label( composite, SWT.NONE );
>> label.setLayoutData( new GridData( SWT.CENTER, SWT.CENTER,
>> true, false ) );
>> label.setText( "Label" );
>> composite.pack();
>>
>> shell.open();
>>
>> while ( !shell.isDisposed() ) {
>> if ( !display.readAndDispatch() ) {
>> display.sleep();
>> }
>> }
>> return 0;
>> }
>> }
Previous Topic:Change the color and weight of Table line
Next Topic:TreeViewer not expanding, and Tree widget
Goto Forum:
  


Current Time: Sat Apr 20 04:01:42 GMT 2024

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

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

Back to the top