HTML 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 




HTML Form
HTML Form


/*******************************************************************************
 * All Right Reserved. Copyright (c) 1998, 2004 Jackwind Li Guojie
 
 * Created on 2004-6-11 15:12:57 by JACK $Id$
 *  
 ******************************************************************************/
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormText;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;

public class SWTTest {

  private FormToolkit toolkit;
  private Form form;
  private Display display;
  private Shell shell;
  private Hyperlink link;
  private Section section1, section2, section3;
  private FormText rtext;
  private Composite client1, client2, client3;
  private Text text;
  private Button button2;
  private Label label;

  static public void main(String args[]) {

    new SWTTest().run();

  }

  private void run() {

    setupShell();

    setupToolkit();

    createFormStructure();

    addLayout();

    addHooks();

    shell.pack();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();

    }

    display.dispose();

  }

  private void createFormStructure() {

    // form

    form = toolkit.createForm(shell);

    form.setText("Eclipse Forms");
    
    Button button = toolkit.createButton(form.getBody()"Test", SWT.NULL);
    
    form.getBody().setLayout(new GridLayout());

    //form.setBackgroundImage(new Image(display, "java2s.gif"));
  }

  private String getHTML() {

    StringBuffer buf = new StringBuffer();

    buf.append("<form>");

    buf.append("<p>");

    buf.append("Here is some plain text for the text to render; ");

    buf.append(
      "this text is at <a href=\"http://www.eclipse.org\" nowrap=\"true\">http://www.eclipse.org</a> web site.");

    buf.append("</p>");

    buf.append("<p>");

    buf.append(
      "<span color=\"header\" font=\"header\">This text is in header font and color.</span>");

    buf.append("</p>");

    buf.append(
      "<p>This line will contain some <b>bold</b> and some <span font=\"text\">source</span> text. ");

    buf.append("We can also add <img href=\"image\"/> an image. ");

    buf.append("</p>");

    buf.append("<li>A default (bulleted) list item.</li>");

    buf.append("<li>Another bullet list item.</li>");

    buf.append(
      "<li style=\"text\" value=\"1.\">A list item with text.</li>");

    buf.append(
      "<li style=\"text\" value=\"2.\">Another list item with text</li>");

    buf.append(
      "<li style=\"image\" value=\"image\">List item with an image bullet</li>");

    buf.append(
      "<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"3.\">A list item with text.</li>");

    buf.append(
      "<li style=\"text\" bindent=\"20\" indent=\"40\" value=\"4.\">A list item with text.</li>");

    buf.append("</form>");

    return buf.toString();

  }

  private void setupToolkit() {

    toolkit = new FormToolkit(display);

  }

  private void setupShell() {

    display = new Display();

    shell = new Shell(display);

    shell.open();

  }

  private void addLayout() {

    // shell

    shell.setLayout(new FillLayout());

    //form

//    form.getBody().setLayout(new TableWrapLayout());
//
//    section1.setLayoutData(new TableWrapData(TableWrapData.FILL));
//
//    section2.setLayoutData(new TableWrapData(TableWrapData.FILL));
//
//    section3.setLayoutData(new TableWrapData(TableWrapData.FILL));
//
//    // client1
//
//    client1.setLayout(new GridLayout());
//
//    // client2
//
//    client2.setLayout(new GridLayout());
//
//    // // client3
//
//    GridLayout layout = new GridLayout();
//
//    client3.setLayout(layout);
//
//    layout.numColumns = 2;
//
//    // client3->text
//
//    text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//
//    // client3->button2
//
//    GridData gd = new GridData();
//
//    gd.horizontalSpan = 2;
//
//    button2.setLayoutData(gd);

  }

  private void addHooks() {

//    section1.addExpansionListener(new ExpansionAdapter() {
//
//      public void expansionStateChanged(ExpansionEvent e) {
//
//        System.out.println("expansionbutton clicked!");
//
//      }
//
//    });
//
//    link.addHyperlinkListener(new HyperlinkAdapter() {
//
//      public void linkActivated(HyperlinkEvent e) {
//
//        System.out.println("Link active: " + e.getLabel());
//
//      }
//
//    });

  }
}
           
       














Related examples in the same category
1.Custom ComponentsCustom Components
2.Email FormEmail Form
3.Simple Form 1Simple Form 1
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.