SelectionListener and DisposeListener : Event « SWT JFace Eclipse « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » SWT JFace Eclipse » EventScreenshots 
SelectionListener and DisposeListener
SelectionListener and DisposeListener


//Send questions, comments, bug reports, etc. to the authors:

//Rob Warner (rwarner@interspatial.com)
//Robert Harris (rbrt_harris@yahoo.com)

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * This class demonstrates SelectionListener and DisposeListener
 */
public class DisposeListenerExample {
  /**
   * The application entry point
   
   @param args the command line arguments
   */
  public static void main(String[] args) {
    Display display = new Display();

    // Create the main window
    Shell mainShell = new Shell(display);
    mainShell.setLayout(new FillLayout());
    mainShell.setText("Big Brother");
    final Label mainMessage = new Label(mainShell, SWT.LEFT);
    mainMessage.setText("Don't even think about it");

    // Create the child shell and the dispose listener
    final Shell childShell = new Shell(mainShell);
    childShell.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent event) {
        // When the child shell is disposed, change the message on the main shell
        mainMessage.setText("Gotcha");
      }
    });
    childShell.setLayout(new FillLayout());
    childShell.setText("little brother");

    // Put a message on the child shell
    new Label(childShell, SWT.LEFT)
        .setText("If you dispose me, my big brother's gonna get you!");

    // Add a button and a listener to the child shell
    Button button = new Button(childShell, SWT.PUSH);
    button.setText("Close Me!");
    button.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        // When the button is pressed, close the child shell
        childShell.close();
      }
    });

    // Open the shells
    mainShell.open();
    childShell.open();

    while (!mainShell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}


           
       
Related examples in the same category
1. ModifyEvent: Temperature Converter JFaceModifyEvent: Temperature Converter JFace
2. Mouse Event Listener Mouse Event Listener
3. Utility class for event handling
4. Demonstrates various listenersDemonstrates various listeners
5. Demonstrates mouse eventsDemonstrates mouse events
6. Demonstrates ControlListenersDemonstrates ControlListeners
7. Demonstrates FocusListenerDemonstrates FocusListener
8. Demonstrates LineBackgroundListenersDemonstrates LineBackgroundListeners
9. Key Listener Example
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.