Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ScrolledComposite question
ScrolledComposite question [message #438338] Tue, 22 June 2004 15:43 Go to next message
Alex Iskold is currently offline Alex IskoldFriend
Messages: 33
Registered: July 2009
Member
Hi,

I am trying to figure out how to make ScrolledComposite stretch its
content and for the scrolls to still appear when necessary. If use
setExpandHorizontal(true)

method, then the contents are stretched, but the scroll does not appear.

Conversely, calling above method with false arg results in scroll bars,
but the content is not stretched. Is it possible to make it look like this:

--------------------------
| | S
| | C
| STRECHED | R
| CONTENT | O
| | L
| | L
--------------------------

Thank you,

Alex
Re: ScrolledComposite question [message #438410 is a reply to message #438338] Wed, 23 June 2004 07:01 Go to previous message
Eclipse UserFriend
Originally posted by: ramim.kauhajoki.fi

Hi,

Here's my solution on this problem. I solved it by setting 3 Inner
Composites. One base which contains a Scrolled composite which contains
THE Composite which holds the widgets. Don't know is this the most simple
way to do this but this works atleast. If you find better one, please post
it here !!


// First create the "base composite"
Composite baseComposite = new Composite(getContainer(), SWT.NONE);
Display display = baseComposite.getShell().getDisplay();
Color white = new Color(display, 255,255,255);
FillLayout layout2 = new FillLayout();
baseComposite.setLayout(layout2);

// create the Composite which can be scrolled up and down
ScrolledComposite scrollComp = new ScrolledComposite(baseComposite,
SWT.H_SCROLL | SWT.V_SCROLL);
scrollComp.setAlwaysShowScrollBars(false);
baseComposite.layout(true);

// create a new Composite inside the ScrolledComposite
// which will contain all the Labels and other widgets
Composite composite = new Composite(scrollComp, 0);
scrollComp.setContent(composite);
composite.setBackground(white);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
composite.setLayout(layout);

// set all the widgets here (on the composite widget)

// and finally maximize the editors's (=composite) width
Point pt = composite.computeSize(SWT.NORMAL, SWT.MAX);
scrollComp.setExpandHorizontal(true);
scrollComp.setExpandVertical(true);
scrollComp.setMinWidth(pt.x);
scrollComp.setMinHeight(pt.y);


I hope this helps you a little bit :)


Alex Iskold wrote:

> Hi,

> I am trying to figure out how to make ScrolledComposite stretch its
> content and for the scrolls to still appear when necessary. If use
> setExpandHorizontal(true)

> method, then the contents are stretched, but the scroll does not appear.

> Conversely, calling above method with false arg results in scroll bars,
> but the content is not stretched. Is it possible to make it look like this:

> --------------------------
> | | S
> | | C
> | STRECHED | R
> | CONTENT | O
> | | L
> | | L
> --------------------------

> Thank you,

> Alex
Previous Topic:Swing components not displaying
Next Topic:OLE Browser getSource XML
Goto Forum:
  


Current Time: Fri Apr 26 17:42:08 GMT 2024

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

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

Back to the top