Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem using Scrolled Composite
Problem using Scrolled Composite [message #443467] Fri, 24 September 2004 23:59 Go to next message
Eclipse UserFriend
Originally posted by: varun.vgupta.gmail.com

Hi,

I m using this design:
[Parentcomposite] GridLayout
[ScrolledComposite] GridData(FILL_BOTH)
[childComposite 1] GridLayout
[Composite 1] RowLayout
[Composite 2] GridLayout and GridData(FILL_BOTH)

I m adding components to [childComposite 1] at runtime. Initially both
[ScrolledComposite] and [Composite 2] are of same size. Also, I m setting
the bounds of [childComposite 1] to be equal to [ScroledComposite], but it
does not appear to be of the same size as scrolledcomposite.

Also, when i add components to [childComposite 1] at runtime, the size of
[ScrolledComposite] will start increasing and that of [Composite 2]
decreases.

Is there some explanation for all this.

Thanx in Advance.

Varun
Re: Problem using Scrolled Composite [message #443544 is a reply to message #443467] Mon, 27 September 2004 19:52 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Are you using 3.1 or 3.0.1?

When you use FILL_BOTH you are saying that you wish to grab excess
horizontal space and you can be squished down to 0 (by default). The
algorithm tries to make the size of the widgets be as close to their default
size as possible. Therefore, if the default size of ScrolledComposite
increases (because you have created more children in childComposite1) and
the size of Parentcomposite is not large enough to show all of its children,
then ScrolledComposite will take up more of the available room than
Composite2. You can change this behaviour by setting the
GridData.widthHint. The GridData.widthHint acts like a minimum width and a
preferred width. If you make the GridData.widthHint of both
ScrolledComposite and Composite2 the same, then they will each grab the same
amount of space.

Consider the following example:

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout(2, false));
Composite c1 = new Composite(shell, SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 100;
c1.setLayoutData(data);

Composite c2 = new Composite(shell, SWT.BORDER);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = 200;
c2.setLayoutData(data);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

If the shell has size 400, then 100+200 = 300. There are 100 pixels left
over so c1 gets 50 and c2 gets 50 resulting in 150 + 250 = 400.
If the shell has size 200, then the widthHint is considered to be a minimum
and c1 has width 100 and c2 has width 200 and the last 100 pixels of c2 are
clipped.

"Varun" <varun.vgupta@gmail.com> wrote in message
news:cj2cc6$kr8$1@eclipse.org...
> Hi,
>
> I m using this design:
> [Parentcomposite] GridLayout
> [ScrolledComposite] GridData(FILL_BOTH)
> [childComposite 1] GridLayout
> [Composite 1] RowLayout
> [Composite 2] GridLayout and GridData(FILL_BOTH)
>
> I m adding components to [childComposite 1] at runtime. Initially both
> [ScrolledComposite] and [Composite 2] are of same size. Also, I m setting
> the bounds of [childComposite 1] to be equal to [ScroledComposite], but it
> does not appear to be of the same size as scrolledcomposite.
>
> Also, when i add components to [childComposite 1] at runtime, the size of
> [ScrolledComposite] will start increasing and that of [Composite 2]
> decreases.
>
> Is there some explanation for all this.
>
> Thanx in Advance.
>
> Varun
>
Previous Topic:(Eclipse Forms) FormText.setText() crash
Next Topic:Enumerate through controls on dialog
Goto Forum:
  


Current Time: Thu Apr 25 19:40:05 GMT 2024

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

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

Back to the top