JFace's MessageDialog : JFace Dialog « 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 » JFace DialogScreenshots 
JFace's MessageDialog
JFace's MessageDialog

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * This class demonstrates JFace's MessageDialog class
 */
public class SendMessage extends ApplicationWindow {
  /**
   * SendMessage constructor
   */
  public SendMessage() {
    super(null);
  }

  /**
   * Runs the application
   */
  public void run() {
    // Don't return from open() until window closes
    setBlockOnOpen(true);

    // Open the main window
    open();

    // Dispose the display
    Display.getCurrent().dispose();
  }

  /**
   * Configures the shell
   
   @param shell the shell
   */
  protected void configureShell(Shell shell) {
    super.configureShell(shell);

    // Set the title bar text and the size
    shell.setText("Send Message");
    shell.setSize(500400);
  }

  /**
   * Creates the main window's contents
   
   @param parent the main window
   @return Control
   */
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(5true));

    // Create a big text box for the message text
    final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 5;
    text.setLayoutData(data);

    // Create the Confirm button
    Button confirm = new Button(composite, SWT.PUSH);
    confirm.setText("Confirm");
    confirm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Error button
    Button error = new Button(composite, SWT.PUSH);
    error.setText("Error");
    error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Information button
    Button information = new Button(composite, SWT.PUSH);
    information.setText("Information");
    information.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Question button
    Button question = new Button(composite, SWT.PUSH);
    question.setText("Question");
    question.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Warning button
    Button warning = new Button(composite, SWT.PUSH);
    warning.setText("Warning");
    warning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the label to display the return value
    final Label label = new Label(composite, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 5;
    label.setLayoutData(data);

    // Save ourselves some typing
    final Shell shell = parent.getShell();

    // Display a Confirmation dialog
    confirm.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        boolean b = MessageDialog.openConfirm(shell, "Confirm", text.getText());
        label.setText("Returned " + Boolean.toString(b));
      }
    });

    // Display an Error dialog
    error.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        MessageDialog.openError(shell, "Error", text.getText());
        label.setText("Returned void");
      }
    });

    // Display an Information dialog
    information.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        MessageDialog.openInformation(shell, "Information", text.getText());
        label.setText("Returned void");
      }
    });

    // Display a Question dialog
    question.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        boolean b = MessageDialog.openQuestion(shell, "Question", text.getText());
        label.setText("Returned " + Boolean.toString(b));
      }
    });

    // Display a Warning dialog
    warning.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        MessageDialog.openWarning(shell, "Warning", text.getText());
        label.setText("Returned void");
      }
    });

    return composite;
  }

  /**
   * The application entry point
   
   @param args the command line arguments
   */
  public static void main(String[] args) {
    new SendMessage().run();
  }
}

           
       
Related examples in the same category
1. JFace's ProgressMonitorDialogJFace's ProgressMonitorDialog
2. JFace's IconAndMessageDialog
3. JFace's InputDialogJFace's InputDialog
4. JFace's ErrorDialog classJFace's ErrorDialog class
5. JFace's TitleAreaDialogJFace's TitleAreaDialog
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.