Email Form : Form « SWT JFace Eclipse « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » SWT JFace Eclipse » FormScreenshots 
Email Form
Email Form


/******************************************************************************
 * All Right Reserved. 
 * Copyright (c) 1998, 2004 Jackwind Li Guojie
 
 * Created on 2004-6-13 18:19:20 by JACK
 * $Id$
 
 *****************************************************************************/



import org.eclipse.jface.action.Action;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;

public class EmailForm  extends ApplicationWindow {

  /**
   @param parentShell
   */
  public EmailForm(Shell parentShell) {
    super(parentShell);
  }


  /* (non-Javadoc)
   * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
   */
  protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new FillLayout());
    
    // Sets up the toolkit.
    FormToolkit toolkit = new FormToolkit(getShell().getDisplay());
    
    // Creates a form instance.
    // Form form = toolkit.createForm(composite);
    ScrolledForm form = toolkit.createScrolledForm(composite);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    
    // Sets title.
    form.setText("Composing an Email Message");
    
    // Adds body contents.
    form.getBody().setLayout(new GridLayout(2false));
    Label label = toolkit.createLabel(form.getBody()"To: ", SWT.NULL);
    Text textTo = toolkit.createText(form.getBody()"");
    textTo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    
    label = toolkit.createLabel(form.getBody()"Subject: ", SWT.NULL);
    Text textSubject = toolkit.createText(form.getBody()"");
    textSubject.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    
    label = toolkit.createLabel(form.getBody()"Message: ", SWT.NULL);
    Text textMessage = toolkit.createText(form.getBody()"");
    textMessage.setLayoutData(new GridData(GridData.FILL_BOTH));
    
    label = toolkit.createLabel(form.getBody()"Option: ", SWT.NULL);
    Button buttonOption = toolkit.createButton(form.getBody()"save a copy", SWT.CHECK);
  
    
    Button buttonClose = toolkit.createButton(form.getBody()"Close", SWT.PUSH);
    GridData gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.END;
    buttonClose.setLayoutData(gridData);
    
    
    // Button button = toolkit.createButton(form.getBody(), "Test", SWT.NULL);  
    
    // Adds tool bar items.
    form.getToolBarManager().add(new Action("Send") {
      public void run() {
        System.out.println("Sending email ...");
      }
    });
    
    form.getToolBarManager().add(new Action("Cancel") {
      public void run() {
        System.out.println("Cancelled.");
      }
    });
    
    form.updateToolBar();

    
    return composite;
  }

  public static void main(String[] args) {
    EmailForm emailForm = new EmailForm(null);
    emailForm.setBlockOnOpen(true);
    emailForm.open();
  }    
  
}


           
       
Related examples in the same category
1. Custom ComponentsCustom Components
2. Simple Form 1Simple Form 1
3. HTML FormHTML Form
ww_w.j___a_v_a_2__s__._c___o___m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.