Tree
final Tree tree = new Tree(shell, SWT.MULTI | SWT.BORDER);
tree.setSize(150, 150);
tree.setLocation(5,5);
TreeItem myComp = new TreeItem(tree, SWT.NONE);
myComp.setText("My Computer");
TreeItem netPlaces = new TreeItem(tree, SWT.NONE);
netPlaces.setText("My Network Places");
TreeItem hardDisk = new TreeItem(myComp, SWT.NONE);
hardDisk.setText("Local Disk (C:)");
Composite
Composite composite = new Composite(shell,SWT.BORDER);
composite.setBounds(10,10,270,250);
composite.setBackground(new Color(display,31,133,31));
Label label = new Label(composite,SWT.NONE);
label.setText("Hello World");
label.setBounds(10,10,200,20);
Group
Group group = new Group(shell, SWT.BORDER);
group.setBounds(30,30,200,200);
group.setText("Group");
Button button = new Button(group, SWT.PUSH);
button.setBounds(10,20,80,20);
button.setText("In a group");
Tab
TabFolder tabFolder = new TabFolder(shell,SWT.NONE);
tabFolder.setBounds(10,10,270,250);
Composite buttonComp = new Composite(tabFolder,SWT.NONE);
Button button1 = new Button(buttonComp,SWT.PUSH);
button1.setSize(100,100);
button1.setText("Hello");
button1.setLocation(0,0);
Button button2 = new Button(buttonComp,SWT.ARROW);
button2.setBounds(150,0,50,50);
TabItem item = new TabItem(tabFolder,SWT.NONE);
item.setText("Buttons");
item.setControl(buttonComp);
Fancy Tabs can be shown using CTabFolder and CTabItem. Reference: http://www.javalobby.org/java/forums/t16488.html
Popup Menu
Menu popupmenu = new Menu(shell, SWT.POP_UP);
MenuItem actionItem = new MenuItem(popupmenu, SWT.PUSH);
actionItem.setText("Other Action");
actionItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
System.out.println("Other Action performed!");
}
});
Menu popupmenu2 = new Menu(shell, SWT.POP_UP);
MenuItem buttonItem = new MenuItem(popupmenu2, SWT.PUSH);
buttonItem.setText("Button Action");
buttonItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
System.out.println("Button Action performed!");
}
});
Composite c1 = new Composite (shell, SWT.BORDER);
c1.setSize (100, 100);
c1.setLocation(25,25);
Button b = new Button(c1, SWT.PUSH);
b.setText("Button");
b.setSize(50,50);
b.setLocation(25,25);
No comments:
Post a Comment