Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Min size of a component? layout question
Min size of a component? layout question [message #556705] Thu, 02 September 2010 11:56 Go to next message
cifroes is currently offline cifroesFriend
Messages: 11
Registered: July 2009
Junior Member

I have a resizable window with 2 columns. the first column is a list of charts to display and the 2nd column contains the charts.

I want that, when only 1 chart is selected it fills all the vertical space for the 2nd column, when there 2 charts they take up half the space, and so on.

I already can do that but my problem is that I also want the charts to not be smaller than 200px. I want to add a scrolled composite to the 2nd column and then specify that I want my charts to not be smaller than 200px.

But I don't know how to set the min size of the charts (the chart is a custom Control of mine). Isn't this possible? I see that I can set the size but won't that defeat my original purpose (1 chart takes up all the available space)?

I hope that is clear and I thank for the help Smile
Re: Min size of a component? layout question [message #556912 is a reply to message #556705] Fri, 03 September 2010 07:06 Go to previous message
Lakshmi ShanmugamFriend
Messages: 276
Registered: July 2009
Location: India
Senior Member

You can use the ScrolledComposite methods, setMinSize , setMinHeight or setMinWidth to do this. You can recompute and reset the minSize based on the number of controls that have to be displayed.

Here is a small example:

public class ScrolledCompositeExample {
  public static void main(String[] args) {
	final int MIN_HEIGHT = 100;
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Button button = new Button(shell, SWT.PUSH);
    button.setText("add another button");
    final ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
    final Composite childComposite = new Composite(sc, SWT.NONE);
    childComposite.setLayout(new FillLayout(SWT.VERTICAL));

    new Button(childComposite, SWT.PUSH | SWT.BORDER).setText("button");
    sc.setMinSize(300, MIN_HEIGHT);

    button.addSelectionListener(new SelectionAdapter() {
    	public void widgetSelected(SelectionEvent e) {
    		new Button(childComposite, SWT.PUSH | SWT.BORDER).setText("button");
    		int height = childComposite.getChildren().length * MIN_HEIGHT;
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {

Lakshmi P Shanmugam

[Updated on: Fri, 03 September 2010 07:07]

Report message to a moderator

Previous Topic:TableViewer setSelection resulting in IllegalArgumentException
Next Topic:Is there a way to remove the blank tree icon inserted when other tree nodes have an icon?
Goto Forum:

Current Time: Sat Dec 14 22:03:21 GMT 2019

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

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

Back to the top