Develop SWT GUI with Eclipse Visual Editor

xiaoxiao2021-03-06  77

Develop SWT GUI with Eclipse Visual Editor

Developing Your Swt Guis with Eclipse Visual Editor

IT small mix (Haili.tian@gmail.com)

NOV.12, 2004

Summary

Preparation

2. Installation

2.1. Installing JRE

2.2. Install Eclipse and other tools

3. Configuration

4. Develop SWT GUI

4.1. Creating a Java project

4.2. New Visual Class

4.3. Complete VE environment

4.4. Simple app

5. Run the SWT APP

6. Conclusion

Author

Summary

This article explains how to develop Java GUI with Eclipse Visual Editor, focusing on the configuration of developing SWT GUI.

Preparation

Eclipse Visual Editor Plug-in needs to use EMF (Eclipse Modeling Framework) and Gef (Graphical Editing Framework), of course, you must have Eclipse SDK and Java JRE, so you have downloaded them before installation.

The version on my machine is:

Ø Java JRE 1.4.1_02 & 1.5.0 (optional version)

Ø Eclipse SDK V3.01

Ø EMF-SDO-XSD-SDK V2.0.1

Ø Gef SDK V3.0.1

Ø VE SDK V1.0

JRE to Sun's website (http://java.sun.com) Download, Eclipse Platform SDK, and other items for other projects of Eclipse to the Eclipse website (http://www.eclipse.org/) download.

Note that the version problem, an release version of any project of Eclipse requires a particular version of SDK and other tools to see its release notes or readme.

2. Installation

2.1. Installing JRE

Now installing JRE is very simple, click Next, you can.

2.2. Install Eclipse and other tools

Pack the Eclipse SDK to your work directory.

Then copy all of Feathers and Plugins inside the EMF, GEF and VE packs to the feathers and plugins directories in the Eclipse.

3. Configuration

After this startup, you can't see the View and New options related to the VE, you need to do the following configuration.

Ø Click on the Window menu to select Customize Perspective ....

Ø Submenus column Select New

Ø Shortcut Categories Choose Java

Ø Sook in the Visual Class in Shortcuts (Figure 1).

Ø Submenus column Select SHOW View

Ø SHORTCUT CATEGORIES Choose Basic

Ø Sook in the Palette (Figure 2) before the Shortcuts.

Figure 1 Select Visual Class

Figure 2, select the Palette View

4. Develop SWT GUI

Visual Editor can help develop AWT (Abstract Window Toolkit), Swing, SWT (Standard Widget Toolkit), and other GUI, but this article is only for SWT.

4.1. Creating a Java project

Create a Java project Eclipseve.

In order to apply SWT, the SWT library must also be included, the method is as follows.

Ø Right-click Eclipseve in Package Explore View, select Properties from the pop-up menu. Ø In the Properties window, select the Java Build Path on the left;

Ø In the Properties window, select the Libraries Tab on the right;

Ø Click the Add Library button;

Ø Select Standard Widget Toolkit (SWT), then Next, Finish, you can. (As shown in Figure 3)

Figure 3, join the SWT library

4.2. New Visual Class

Create a package org.eclipse.ve.test before creating a Visual Class.

Then right-click ORG.ECLIPSE.VE.TEST, and then select New> Visual Class from the pop-up menu, Figure four screen appears.

Figure 4, create a Visual Class

In Name, fill in MyFirstvisualClass.

SWT / Application is selected in STYLE.

Others choose or fill in the figure.

Click Finish.

The subsequent interface is shown in Figure 5.

Figure 5, initial interface

4.3. Complete VE environment

Why don't you do Wysiwyg (see what you get out)? Look carefully to the right of the picture, the original Palette is initially hidden.

Click

Palette is coming out (you can also call up the Palette: Window | Show View | Palette by the menu, remember 3. Palette in the configuration?).

The current interface is as shown in Figure 6 (1) or Figure 6 (2).

Figure 6 (1), VE development environment (1)

Figure 6 (2), VE development environment (2)

In order to move directly to the various attributes of Widget, you can open the Properties View, where you can do it.

Open the Properties View method: If the Properties View is already open, click it directly, otherwise, from Menu, Method Windows | Show View | Basic | Properties

The current interface is like Figure 6 (3).

Figure 6 (3), VE complete development environment (3)

4.4. Simple app

Do a simple app below

Select the shell and change its text to "My First Ve Application" in the Properties View;

Select a label from Palette to put it on the shell and change its text to "Hello, World!" In the Properties View.

The result of the design now is like Figure 7.

Figure 7, the first VE development program

Below is the code automatically generated by VE

5. Run the SWT APP

Running the SWT App from the Run menu is selected from the RUN ...

In the pop-up window, select Java Application in Configurations, click the New button;

In the right arguments tab, VM Arguments is written to -Djava.library.path =

(For example, my is: f: /eclipse-3.0.1/eclipse/plugins/org.eclipse.swt.win32_3.0.1/OS/Win32/x86) as shown in Figure 8

Figure 8. Running configuration

Click Apply;

Click Run.

Congratulations, huh, huh, the cute picture has appeared

6. Conclusion

Automatically generated code is still very ugly, which cannot be fully replaced by people's labor, but the characteristics you have obtained, you can make it easy for you to lay out those Widgets.

About author

Tian Hai Li (IT small mix), system analyst, 2004] graduated from Nanjing University (Software Architecture direction), main interest: embedded system application architecture, Java / Eclipse, Linux technology, previewing the master's and currently engaged in embedded System development. You can contact him with Haili.tian@gmail.com, to http://blog.9cbs.net/thl789/ or http://spacs.msn.com/members/thl789/ look at his article.

THL789

9CBS certified blog expert

System analyst

Android

artificial intelligence

转载请注明原文地址:https://www.9cbs.com/read-92403.html

New Post(0)