Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public class TestMeOut
  2. {
  3. public static void main(final String[] args)
  4. {
  5.  
  6. final Display display = new Display();
  7. final Shell shell = new Shell(display);
  8. shell.setLayout(new GridLayout(1, false));
  9.  
  10. final Shell shell2 = new Shell(shell);
  11. shell2.setLayout(new GridLayout());
  12.  
  13. final Button btn = new Button(shell, SWT.PUSH);
  14. final Button btn2 = new Button(shell2, SWT.PUSH);
  15.  
  16. btn.setText("Test me");
  17. btn2.setText("I steal focus");
  18.  
  19. btn.addSelectionListener(new SelectionAdapter()
  20. {
  21. @Override
  22. public void widgetSelected(final SelectionEvent e)
  23. {
  24. shell2.setVisible(true);
  25. }
  26. });
  27.  
  28. btn2.addSelectionListener(new SelectionAdapter()
  29. {
  30. @Override
  31. public void widgetSelected(final SelectionEvent e)
  32. {
  33. shell2.setVisible(false);
  34. }
  35. });
  36.  
  37. shell.pack();
  38. shell.open();
  39.  
  40. shell.addShellListener(new ShellListener()
  41. {
  42.  
  43. public void shellIconified(final ShellEvent e)
  44. {
  45. }
  46.  
  47. public void shellDeiconified(final ShellEvent e)
  48. {
  49. }
  50.  
  51. public void shellDeactivated(final ShellEvent e)
  52. {
  53. System.out.println("Deactivated! This isn't supposed to happen.");
  54. }
  55.  
  56. public void shellClosed(final ShellEvent e)
  57. {
  58. }
  59.  
  60. public void shellActivated(final ShellEvent e)
  61. {
  62. System.out.println("Activated!");
  63. }
  64. });
  65.  
  66. shell2.pack();
  67. shell2.open();
  68. shell2.setVisible(false);
  69.  
  70. while (!shell.isDisposed())
  71. {
  72. if (!display.readAndDispatch())
  73. display.sleep();
  74. }
  75. display.dispose();
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement