Email Form : Form « SWT JFace Eclipse « Java

Home
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.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » SWT JFace Eclipse » Form 




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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.