Eclipse Practical Tutorial (ve plugin usage)

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

Long heard of Eclipse's famous, browsing a lot of articles on Eclipse, heard that with Swt,jface can design a local operating system interface style Dongdong, if running on XP, it is not very satisfying customer, the near future to do a desktop system, ^_^ ... Want to trying under.

In eclipse, of course, I was Shang the last two days., download a lot of things, read a lot of articles, finally made a pass, now to share with you. I did not find the complete installation strategy, now write a new ... It is recommended that you first browse through the Eclipse Web site http://www.eclipse.org, especially the Projects connection, where Eclipse Projiect, and Eclipse Tools Project.

Eclipse (the Eclipse SDK is the latest 3.0.2) is a platform, where 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 the novice confused ...

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

Do not rush to download these dongdong, I was Shang suffered ...

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

Now look at its download requirements!!!!! Originally ve can 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 own time.

Okay, here we go. Build a download folder.

Download ve (1.0.2.1)

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

Extract the Eclipse SDK 3.0.1, and copy the Eclipse folder in the decompression to d:/

Look inside the contents, mainly the Plugins,features

Extract the EMF to the/EMF folder, copy the Emf/plugins to the D:/eclipse/plugins, and emf/features the contents to the D:/eclipse/features

VE,GEF Operation Ditto ...

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

Because the program running SWT uses the local library, copy the *.dll under d:/eclipse/plugins/org.eclipse.swt.win32_3.0.1/os/win32/x86 copy 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.

Now start D:/eclipse/eclipse.exe.

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

Eclipse will automatically recognize your JRE.

Actual combat!

Start Eclipse, see Welcome project, yes ... The interface is very attractive!

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

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

Select your project Hello. Select the new Icon button, at the top left. Select Visual Class, click Next, Source folder is the default project folder, package fill in test, Name fill in Frmhello, expand the left SWT selection Shell, tick 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.

The mouse moves to the right palette (the vertical one) puts a label, a button, and a textarea on the shell.

Select Label, the Properties property bar on the next side can be set, >text to fill in Hello World

Select the Properties property bar on the next side of the button to be set and >text to fill in the Click Me.

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

You can also make other style settings, but you cannot operate if the JDK version is not correct. Wrong ...

All code:

/*

* Created on 2005-4-20

*

* TODO to change the template of 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 of this generated type comment go

* 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 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 great job will be ready soon.  Select the run icon, the black down arrow next to the green button on the toolBar. Select->run ..., select the Java application on the left, and click New below. Select the Middle Main tab, and Project chooses Hello, main class: Select Test.  Frmhello. Click the Run button.

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

Note: To close the current form with Dispose () on it, 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.