List of usage examples for org.eclipse.swt.widgets Button getDisplay
public Display getDisplay()
Display
that is associated with the receiver. From source file:MainClass.java
public static void main(String[] a) { final Display d = new Display(); final Shell shell = new Shell(d); shell.setSize(250, 200);/*www .jav a2 s.co m*/ final String RUN = "Press to Run"; final String IS_RUNNING = "Running..."; shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText(RUN); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { button.setText(IS_RUNNING); BusyIndicator.showWhile(button.getDisplay(), new SleepThread(1000)); button.setText(RUN); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:BusyIndicatorDemo.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("BusyIndicator Test"); shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText(RUN);/*from w w w. j a v a 2 s . c o m*/ button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Change the button's text button.setText(IS_RUNNING); // Show the busy indicator BusyIndicator.showWhile(button.getDisplay(), new SleepThread(SLEEP_TIME)); // Thread has completed; reset the button's text button.setText(RUN); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:BusyIndicatorTest.java
/** * Create the window's contents/*w ww .j a v a 2s . c o m*/ * * @param shell the parent shell */ private void createContents(Shell shell) { shell.setLayout(new FillLayout()); final Button button = new Button(shell, SWT.PUSH); button.setText(RUN); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Change the button's text button.setText(IS_RUNNING); // Show the busy indicator BusyIndicator.showWhile(button.getDisplay(), new SleepThread(SLEEP_TIME)); // Thread has completed; reset the button's text button.setText(RUN); } }); }