List of usage examples for org.eclipse.swt.widgets Label setLocation
public void setLocation(int x, int y)
From source file:org.eclipse.swt.snippets.Snippet34.java
public static void main(String[] args) { Display display = new Display(); Image image = new Image(display, 16, 16); Color color = display.getSystemColor(SWT.COLOR_RED); GC gc = new GC(image); gc.setBackground(color);/*from w ww . j a va 2s . c om*/ gc.fillRectangle(image.getBounds()); gc.dispose(); Shell shell = new Shell(display); shell.setText("Snippet 34"); Label label = new Label(shell, SWT.BORDER); Rectangle clientArea = shell.getClientArea(); label.setLocation(clientArea.x, clientArea.y); label.setImage(image); label.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet276.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 276"); shell.setBounds(200, 200, 400, 400); Label label = new Label(shell, SWT.NONE); label.setText("click in shell to print display-relative coordinate"); Listener listener = event -> {/*from w w w . j av a2 s . c o m*/ Point point = new Point(event.x, event.y); System.out.println(display.map((Control) event.widget, null, point)); }; shell.addListener(SWT.MouseDown, listener); label.addListener(SWT.MouseDown, listener); Rectangle clientArea = shell.getClientArea(); label.setLocation(clientArea.x, clientArea.y); label.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
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); label.pack();/*from w w w . ja v a2 s . c o m*/ 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(); }