Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestMeOut
- {
- public static void main(final String[] args)
- {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new GridLayout(1, false));
- final Shell shell2 = new Shell(shell);
- shell2.setLayout(new GridLayout());
- final Button btn = new Button(shell, SWT.PUSH);
- final Button btn2 = new Button(shell2, SWT.PUSH);
- btn.setText("Test me");
- btn2.setText("I steal focus");
- btn.addSelectionListener(new SelectionAdapter()
- {
- @Override
- public void widgetSelected(final SelectionEvent e)
- {
- shell2.setVisible(true);
- }
- });
- btn2.addSelectionListener(new SelectionAdapter()
- {
- @Override
- public void widgetSelected(final SelectionEvent e)
- {
- shell2.setVisible(false);
- }
- });
- shell.pack();
- shell.open();
- shell.addShellListener(new ShellListener()
- {
- public void shellIconified(final ShellEvent e)
- {
- }
- public void shellDeiconified(final ShellEvent e)
- {
- }
- public void shellDeactivated(final ShellEvent e)
- {
- System.out.println("Deactivated! This isn't supposed to happen.");
- }
- public void shellClosed(final ShellEvent e)
- {
- }
- public void shellActivated(final ShellEvent e)
- {
- System.out.println("Activated!");
- }
- });
- shell2.pack();
- shell2.open();
- shell2.setVisible(false);
- while (!shell.isDisposed())
- {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement