List of usage examples for org.eclipse.swt.widgets Label Label
public Label(Composite parent, int style)
From source file:AccessibleListenerAdding.java
License:asdf
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Label label = new Label(shell, SWT.NONE); label.setText("asdf"); Accessible accessible = label.getAccessible(); accessible.addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { super.getName(e); e.result = "Speak this instead of the text"; System.out.println("Accessible"); }// www. j ava2s.c om }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Sliders"); shell.setSize(300, 200);/*from ww w. jav a 2 s . c om*/ final Label label = new Label(shell, SWT.NONE); label.setText("Move the slider"); label.setBounds(0, 20, 150, 15); final Slider slider = new Slider(shell, SWT.HORIZONTAL); slider.setBounds(0, 40, 200, 20); final Text text = new Text(shell, SWT.BORDER); text.setBounds(0, 100, 200, 25); slider.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { String outString = "Event: SWT.NONE"; switch (event.detail) { case SWT.ARROW_DOWN: outString = "Event: SWT.ARROW_DOWN"; break; case SWT.ARROW_UP: outString = "Event: SWT.ARROW_UP"; break; case SWT.DRAG: outString = "Event: SWT.DRAG"; break; case SWT.END: outString = "Event: SWT.END"; break; case SWT.HOME: outString = "Event: SWT.HOME"; break; case SWT.PAGE_DOWN: outString = "Event: SWT.PAGE_DOWN"; break; case SWT.PAGE_UP: outString = "Event: SWT.PAGE_UP"; break; } outString += " Position: " + slider.getSelection(); text.setText(outString); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:AccessibleControlListenerAdding.java
License:asdf
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Label label = new Label(shell, SWT.NONE); label.setText("asdf"); Accessible accessible = label.getAccessible(); accessible.addAccessibleControlListener(new AccessibleControlAdapter() { public void getState(AccessibleControlEvent e) { super.getState(e); System.out.println("AccessibleControlListener"); }/*from w w w . j a v a2 s. c o m*/ }); 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 ww. j a v a 2 s.com s.setText("A FormLayout Example"); s.setLayout(new FormLayout()); final Label l1 = new Label(s, SWT.RIGHT); l1.setText("First Name"); FormData fd = new FormData(); fd.top = new FormAttachment(10, 10); fd.left = new FormAttachment(0, 10); fd.bottom = new FormAttachment(30, 0); fd.right = new FormAttachment(40, 0); l1.setLayoutData(fd); final Label l2 = new Label(s, SWT.RIGHT); l2.setText("Last Name"); fd = new FormData(); fd.top = new FormAttachment(l1, 5); fd.left = new FormAttachment(0, 10); fd.bottom = new FormAttachment(40, 0); fd.right = new FormAttachment(40, 0); l2.setLayoutData(fd); final Text t1 = new Text(s, SWT.BORDER | SWT.SINGLE); fd = new FormData(); fd.top = new FormAttachment(l1, 0, SWT.TOP); fd.left = new FormAttachment(l1, 10); t1.setLayoutData(fd); final Text t2 = new Text(s, SWT.BORDER | SWT.SINGLE); fd = new FormData(); fd.top = new FormAttachment(l2, 0, SWT.TOP); fd.left = new FormAttachment(l2, 10); t2.setLayoutData(fd); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.MIN); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.MIN"); d.setBounds(20, 20, 100, 100);/*from ww w .j ava 2 s.com*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.MAX); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.MAX"); d.setBounds(20, 20, 100, 100);/*from w ww. jav a2 s . co m*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet93.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.NONE); GC gc = new GC(label); Point size = gc.textExtent("Hello"); gc.dispose();/*from w w w . j a v a2s .com*/ label.setText("Hello -> " + size); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.TOOL); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.TOOL"); d.setBounds(20, 20, 100, 100);/*from w w w .j a v a 2s . co m*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.TITLE); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.TITLE"); d.setBounds(20, 20, 100, 100);// ww w . ja va 2s .com shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Sash One"); // The SWT.BORDER style Decorations d = new Decorations(shell, SWT.CLOSE); d.setLayoutData(new GridData(GridData.FILL_BOTH)); d.setLayout(new FillLayout()); Label l = new Label(d, SWT.CENTER); l.setText("SWT.CLOSE"); d.setBounds(20, 20, 100, 100);/*from w ww .j ava 2s. c om*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }