SWT and JFACE outside Eclipse Workbench

xiaoxiao2021-03-06  73

Use SWT and JFACE outside Eclipse Workbench if you are tired of AWT and SWING faces ...

Still start with Eclipse! Here is the relationship between Eclipse Workbench, JFACE, and SWT.

[PRE] -------------------

Eclipse Workbench |

| -------------

| | JFACE |

----- -------------

| SWT |

------------------ [/ pre]

What is SWT and JFACE? * SWT is a window component set and a graphics library, which is integrated into this unit window system but has an API independent of the OS.

* JFACE is the UI toolbox implemented with SWT, which simplifies common UI programming tasks.

JFACE is independent of the window system in its API and implementation, which is designed to use SWT without hiding it.

Ok, I read some concepts, or use code! Before you start, you have successfully installed Eclipse.

Open Eclipse, create a new Java Project, then add the following jar to you, in your plugins directory in your Eclipse installation directory:

Org.eclipse.jface_2.1.0 / jface.jar

Org.eclipse.core.boot_2.1.0 / boot.jar

Org.eclipse.swt.win32_2.1.0 / ws / win32 / swt.jar

Org.eclipse.ui.Workbench_2.1.0 / Workbench.jar

Org.eclipse.core.Runtime_2.1.0 / runtime.jar

Note: This example is listed here and the package required for general applications.

If you need these packet source code, you can find it in /plus/org.eclipse.platform.Source_2.1.0/src in your Eclipse installation directory.

Create our HelloWorld!

Import org.eclipse.jface.window.ApplicationWindow;

Import org.eclipse.swt.widgets.display;

public

Class HelloWorld

{

public

Static

Void main (String [] args

{

ApplicationWindow W =

New ApplicationWindow (NULL);

W.SetBlockonopen

True);

W.Open ();

Display.getcurrent (). Dispose ();

}

}

It's that simple? It is simple to it, even "Hello World" did not see :)

However, it is enough to let you know if your environment can run a SWT & JFACE program.

Click Menu Run-> Run as-> JavaApplication. You will find a lot of mistakes!

Don't worry, click Run-> Run ..., then write the following parameters in the VM Arguments in the arguments page:

-Djava.library.path = c: /eclipse-2.1.0/plugins/org.eclipse.swt.win32_2.1.0/OS/Win32/x86/

Then click the RUN button! OK, you will find a blank form on the screen, which means that we succeed.

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

New Post(0)