List of usage examples for org.eclipse.swt.widgets Button setBounds
public void setBounds(int x, int y, int width, int height)
From source file:CursorSetControl.java
public static void main(String[] args) { Display display = new Display(); Cursor cursor = new Cursor(display, SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.open();/*from ww w . jav a 2 s. co m*/ final Button b = new Button(shell, 0); b.setBounds(10, 10, 200, 200); b.setCursor(cursor); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } cursor.dispose(); display.dispose(); }
From source file:Snippet44.java
public static void main(String[] args) { Display display = new Display(); final Cursor cursor = new Cursor(display, SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.open();/*from www. j a va 2s . co m*/ final Button b = new Button(shell, 0); b.setBounds(10, 10, 200, 200); b.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { b.setCursor(cursor); } }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } cursor.dispose(); display.dispose(); }
From source file:ControlBounds.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button = new Button(shell, SWT.PUSH); button.setBounds(20, 20, 200, 20); shell.setSize(260, 120);/*from w w w . j a va2 s . com*/ shell.open(); System.out.println("------------------------------"); System.out.println("getBounds: " + button.getBounds()); System.out.println("getLocation: " + button.getLocation()); System.out.println("getSize: " + button.getSize()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:Snippet127.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button1 = new Button(shell, SWT.PUSH); button1.setBounds(10, 10, 80, 30); button1.setText("no traverse"); button1.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false;//from w ww .j a va 2 s . com } } } }); Button button2 = new Button(shell, SWT.PUSH); button2.setBounds(100, 10, 80, 30); button2.setText("can traverse"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CanvasControlAdd.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Canvas Example"); shell.setLayout(new FillLayout()); Canvas canvas = new Canvas(shell, SWT.NONE); Button button = new Button(canvas, SWT.PUSH); button.setBounds(10, 10, 300, 40); button.setText("You can place widgets on a canvas"); canvas.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle rect = ((Canvas) e.widget).getBounds(); e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawFocus(5, 5, rect.width - 10, rect.height - 10); e.gc.drawText("You can draw text directly on a canvas", 60, 60); }//from w w w. j a va 2 s . c o m }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:NoLayoutSimple.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button = new Button(shell, SWT.PUSH); button.setText("No layout"); button.setBounds(5, 5, 50, 150); shell.pack();/* w w w .j a va 2s . c o m*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ButtonClass.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setSize(200, 200);/*from w w w . j a va 2s . co m*/ shell.setText("Button Example"); final Button button = new Button(shell, SWT.PUSH); button.setBounds(40, 50, 50, 20); button.setText("Click Me"); final Text text = new Text(shell, SWT.BORDER); text.setBounds(100, 50, 70, 20); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent event) { text.setText("No problem"); } public void widgetDefaultSelected(SelectionEvent event) { text.setText("No worries!"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);/*from w w w. j ava2 s.c om*/ s.setText("A List Example"); final List l = new List(s, SWT.MULTI | SWT.BORDER); l.setBounds(50, 50, 75, 75); l.add("Item One"); l.add("Item Two"); l.add("Item Three"); l.add("Item Four"); l.add("Item Five"); final Button b1 = new Button(s, SWT.PUSH | SWT.BORDER); b1.setBounds(150, 150, 50, 25); b1.setText("Click Me"); b1.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String selected[] = l.getSelection(); for (int i = 0; i < selected.length; i++) { System.out.println(selected[i]); } } }); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display d = new Display(); final Shell s = new Shell(d); s.setSize(250, 200);/*from w w w . j a v a 2 s . c o m*/ s.setText("A MouseListener Example"); final Button b = new Button(s, SWT.PUSH); b.setText("Push Me"); b.setBounds(20, 50, 55, 25); s.open(); b.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent e) { System.out.println(e.x); } }); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:WidgetBoundsSetting.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10, 10, 200, 200);//ww w. j av a2s. c o m Button button1 = new Button(shell, SWT.PUSH); button1.setText("&Typical button"); button1.setBounds(10, 10, 180, 30); Button button2 = new Button(shell, SWT.PUSH); button2.setText("&Overidden button"); button2.setBounds(10, 50, 180, 30); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }