Eclipse Practical Tutorial (ve plugin use detailed)

Source: Internet
Author: User
Tags stub win32
using Eclipse's ve (Visual Editor)

Long heard of Eclipse's famous, browsing a lot of articles about eclipse, I heard that with Swt,jface can design a local operating system interface style of East, if running on XP, is not very customer satisfaction, recently to do a desktop system, ^_^ ... Want to trying under.

With eclipse of course to pretend to say, these two days I was halftone suffered ..., downloaded a lot of things, read a lot of articles, finally tuned, and now to share the next. I did not find the complete installation strategy, now write a new ... We recommend that you first browse the Eclipse Web site http://www.eclipse.org, especially the Projects connection, where the Eclipse Projiect, and Eclipse Tools Project.

Eclipse (the latest Eclipse SDK is 3.0.2) is a platform in which the JDT,PDE are integrated in the Eclipse download, Swt,jface development package is also, do not care too much, some articles say a lot, but let novice confused ...

The Eclipse Tool Project is primarily used. Graphical Editor Framework (GEF) Project, EMF, VE

Don't rush to download these things, I am halftone suffering ...

With eclipse, of course, you want to use its visual programming (Visual Edit Project) plug-in. Now the newest is VE1.0.2.1 download page http://www.eclipse.org/vep/

Now look at its download requirements!!!!! The original ve only and the corresponding version of the Gef,emf,eclipse SDK, work together, if you previously downloaded the other high version, are Zaojian, the key is to delay their time.

All right, Raiders, get started. Create a download folder.

Download ve (1.0.2.1)

Download the Eclipse SDK 3.0.1, EMF 2.0.1, GEF3.0.1 in the same page requirements

Unzip the eclipse SDK 3.0.1 and copy the Eclipse folder in the unzip to the d:/

Look inside the content, mainly plugins,features

Unzip the EMF to the/emf folder, copy everything from Emf/plugins to D:/eclipse/plugins, Emf/features to D:/eclipse/features

VE,GEF Operation Ditto ...

Importantly, Eclipse 3.0.1 needs to be JDK1.4.2, so install it first. The path setting for the JDK is no longer said .../bin,/lib,/jdk1.4.2

Since the program that runs SWT uses the local library, copy the *.dll under D:/eclipse/plugins/org.eclipse.swt.win32_3.0.1/os/win32/x86 to the/bin directory under the JDK path,  The running program can be found automatically. These problems have been bothering me for a long time.

Start D:/eclipse/eclipse.exe Now

^_^ ^_^, it's all OK.

Eclipse will automatically recognize your JRE.

Actual combat!

Start Eclipse and see Welcome project, Good ... The interface is fascinating!

Create a new project File->new->project the Project Wizard and select Java Project. ->next Input Project Name:hello eclipse automatically builds a workspace working folder for you, your project is here, D:/eclipse/workspace click End. A new project was built.

Add SWT ToolKit, menu project->properties Select the Java Build Path on the left, select the Libraries tab on the right, click the Add Library button, select the standard Widget Toolkit (swt) Click Next and select the Include support for JFace library end. This allows you to use the SWT JFace control.

Select your project Hello. Select the New Icon button at the top left of the upper end. Select Visual Class, click Next, the Source Folder is the default project Folder, the package fills in test, Name fills in the Frmhello, expands the SWT selection Shell on the left, tick the public static void Main (string[] args), constructors from superclass, inherited abstract methods. End.

Eclipse Auto-Start VE .... Look at those windows ... More familiar with: A visual editing window appears.

Move the mouse to the right of the palette (the vertical one) put a label, a button, a textarea on the shell.

With the label selected, the Properties property bar on the lower side can be set, >text fill in Hello World

Select the Button on the bottom side of the Properties property bar can be set, >text fill in click Me.

Select the button right and Events->add events.  Select Mouse-mouseadapter->mousedown. The corresponding code is generated automatically. Add the following code (blue section)

Other styles can be set up, but cannot be manipulated if the JDK version is not correct. Wrong ...

All code:

/*

* Created on 2005-4-20

*

* TODO to change the template for this generated file go

* Window-preferences-java-code Style-code Templates

*/

Package test;

Import Org.eclipse.swt.widgets.Label;

Import Org.eclipse.swt.SWT;

Import Org.eclipse.swt.widgets.Button;

Import Org.eclipse.swt.widgets.Text;

/**

* @author w19284

*

* TODO to change the template for this generated type comment go to

* Window-preferences-java-code Style-code Templates

*/

public class Frmhello {

Private Org.eclipse.swt.widgets.Shell Sshell = null; @jve:d ecl-index=0:visual-constraint= "41,12"

Private label label = NULL;

Private button button = null;

Private Text TextArea = null;

/**

*

*/

Public Frmhello () {

Super ();

TODO auto-generated Constructor stub

}

public static void Main (string[] args) {

/* Before this is run, being sure to set up the following in the launch configuration

* (ARGUMENTS->VM Arguments) for the correct SWT library path.

* The following is a Windows example:

*-djava.library.path= "installation_directory/plugins/org.eclipse.swt.win32_3.0.0/os/win32/x86"

*/

Org.eclipse.swt.widgets.Display Display = Org.eclipse.swt.widgets.Display.getDefault ();

Frmhello ThisClass = new Frmhello ();

Thisclass.createsshell ();

ThisClass.sShell.open ();

while (!thisclass.sshell.isdisposed ()) {

if (!display.readanddispatch ()) display.sleep ();

}

Display.dispose ();

}

/**

* This method initializes Sshell

*/

private void Createsshell () {

Sshell = new Org.eclipse.swt.widgets.Shell ();

Label = new label (Sshell, SWT. NONE);

button = New button (Sshell, SWT. NONE);

TextArea = new Text (Sshell, SWT. MULTI | Swt. WRAP | Swt. V_scroll);

Sshell.settext ("Shell");

Sshell.setbackground (Org.eclipse.swt.widgets.Display.getDefault (). Getsystemcolor (org.eclipse.swt.SWT.COLOR_ Title_background_gradient));

Label.setbounds (New Org.eclipse.swt.graphics.Rectangle (167,5,96,24));

Label.settext ("Hello World");

Label.setbackground (Org.eclipse.swt.widgets.Display.getDefault (). Getsystemcolor (Org.eclipse.swt.SWT.COLOR_INFO _background));

Label.setfont (New Org.eclipse.swt.graphics.Font (Org.eclipse.swt.widgets.Display.getDefault), "Times New Roman", 12 , Org.eclipse.swt.SWT.BOLD));

Button.setbounds (New Org.eclipse.swt.graphics.Rectangle (152,34,123,24));

Button.settext ("click Me");

Button.setfont (New Org.eclipse.swt.graphics.Font (Org.eclipse.swt.widgets.Display.getDefault), "Times New Roman", (Org.eclipse.swt.SWT.NORMAL));

Textarea.setbounds (New Org.eclipse.swt.graphics.Rectangle (64,70,323,123));

Sshell.setsize (New Org.eclipse.swt.graphics.Point (451,232));

Button.addmouselistener (New Org.eclipse.swt.events.MouseAdapter () {

public void MouseDown (Org.eclipse.swt.events.MouseEvent e) {

System.out.println ("MouseDown ()"); TODO auto-generated Event stub mouseDown ()

Textarea.settext (Textarea.gettext () + "| Hello,eclipse ");

}

});

}

}

Well, the merit is gaocheng immediately.  Select the run icon, the black down arrow next to the green button on the ToolBar. Select->run., select Java application on the left to click New. Select the Middle Main tab, Project Select Hello, main class: Select Test.  Frmhello. Click the Run button.

The interface comes out ...., you can click the Run icon and run the program. Tap the click Me to see the changes in textarea ...

Note: Closing the current form with Dispose () is possible, if you want to exit the program, use System.exit (0), the above code is SWT's

Here are some of my own code:

public void keypressed (Java.awt.event.KeyEvent e) {

KeyPress Events

Frmlogin frmlogin=new Frmlogin ();

The following Setup Mode window

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.