List of usage examples for org.eclipse.swt.widgets Label pack
public void pack()
From source file:CompViewer.java
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);/*from w w w .j av a 2s . co m*/ 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(); }
From source file:CoolBarExamples.java
public CoolBarExamples() { shell.setLayout(new GridLayout()); final CoolBar coolBar = new CoolBar(shell, SWT.NONE); coolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // cool item with a text field. CoolItem textItem = new CoolItem(coolBar, SWT.NONE); Text text = new Text(coolBar, SWT.BORDER | SWT.DROP_DOWN); text.setText("TEXT"); text.pack();/*from ww w. jav a 2s.c o m*/ Point size = text.getSize(); textItem.setControl(text); textItem.setSize(textItem.computeSize(size.x, size.y)); // cool item with a label. CoolItem labelItem = new CoolItem(coolBar, SWT.NONE); Label label = new Label(coolBar, SWT.NONE); label.setText("LABEL"); label.pack(); size = label.getSize(); labelItem.setControl(label); labelItem.setSize(textItem.computeSize(size.x, size.y)); // cool item with a button. CoolItem buttonItem = new CoolItem(coolBar, SWT.NONE | SWT.DROP_DOWN); Composite composite = new Composite(coolBar, SWT.NONE); composite.setLayout(new GridLayout(2, true)); Button button1 = new Button(composite, SWT.PUSH); button1.setText("Button 1"); button1.pack(); Button button2 = new Button(composite, SWT.PUSH); button2.setText("Button 2"); button2.pack(); composite.pack(); size = composite.getSize(); buttonItem.setControl(composite); buttonItem.setSize(buttonItem.computeSize(size.x, size.y)); // // Test cool item adding method. // Label label2 = new Label(coolBar, SWT.NONE); // label2.setText("label2"); // addControlToCoolBar(label2, SWT.DROP_DOWN, coolBar); try { setState(coolBar, new File("coolbar.state")); } catch (IOException e1) { e1.printStackTrace(); } shell.addListener(SWT.Close, new Listener() { public void handleEvent(Event event) { try { saveState(coolBar, new File("coolbar.state")); } catch (IOException e) { e.printStackTrace(); } } }); shell.setSize(300, 120); // shell.pack(); shell.open(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }