Group Label and Button : Group « SWT JFace Eclipse « Java






Group Label and Button

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;

public class Ch3_Composite extends Composite {

  public Ch3_Composite(Composite parent) {
    super(parent, SWT.NONE);
    parent.getShell().setText("Chapter 3 Composite");

    Ch3_Group cc1 = new Ch3_Group(this);
    cc1.setLocation(0, 0);
    cc1.pack();

    Ch3_SashForm cc2 = new Ch3_SashForm(this);
    cc2.setLocation(125, 25);
    cc2.pack();

    pack();
  }
}

class Ch3_Group extends Composite {
  public Ch3_Group(Composite parent) {
    super(parent, SWT.NONE);
    Group group = new Group(this, SWT.SHADOW_ETCHED_IN);
    group.setText("Group Label");

    Label label = new Label(group, SWT.NONE);
    label.setText("Two buttons:");
    label.setLocation(20, 20);
    label.pack();

    Button button1 = new Button(group, SWT.PUSH);
    button1.setText("Push button");
    button1.setLocation(20, 45);
    button1.pack();

    Button button2 = new Button(group, SWT.CHECK);
    button2.setText("Check button");
    button2.setBounds(20, 75, 90, 30);
    group.pack();
  }
}

class Ch3_SashForm extends Composite {
  public Ch3_SashForm(Composite parent) {
    super(parent, SWT.NONE);

    SashForm sf = new SashForm(this, SWT.VERTICAL);
    sf.setSize(120, 80);

    Button button1 = new Button(sf, SWT.ARROW | SWT.UP);
    button1.setSize(120, 40);

    Button button2 = new Button(sf, SWT.ARROW | SWT.DOWN);
    button2.setBounds(0, 40, 120, 40);
  }
}



           
       








Related examples in the same category

1.Group ExamplesGroup Examples
2.Demonstrates groupsDemonstrates groups
3.Group ExampleGroup Example
4.Group Example 2Group Example 2
5.SWT Group demoSWT Group demo