Jun
10
2007

Creando HelloWorld con JFace (SWT) en Eclipse 3.2 y problemas comunes

1) Necesitamos el plugin SWT, descargarlo de www.eclipse.org para la plataforma específica y descomprimirlo en en temporal, en mi caso:yo descargué: swt-M20070212-1330-gtk-linux-x86.zip

2) Crear un proyecto java, importar el archivo anterior descomprimido. referencia eclipse paso a paso

3) Ahora crear un proyecto Java HelloJFace, incluyendo en el build Path el otro proyecto de SWT recién creado, así tendremos las clases SWT disponibles para HelloJFace.

4) También incluir dentro del build Path “Libraries” de HelloJFace las siguientes clases que ya vienen con el Eclipse 3.2:

org.eclipse.jface_3.2.2.M2…jar
org.eclipse.jface.text_3.2.2.r322_…jar
org.eclipse.equinox.common_3.2.0.v2…jar
org.eclipse.core.commands_3.2….jar

5)En el proyecto recién creado, crear una clase con el nombre HelloJface.java con el siguiente contenido:

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;

public class HelloJface extends ApplicationWindow {
public HelloJface() {
super(null)
}

public void run() {
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
}

protected Control createContents(Composite parent) {
Label label = new Label(parent, SWT.CENTER);
label.setText(“Hello JFace”);
return label;
}

public static void main(String[] args) {
new HelloJface().run();
}
}

6)

Ejecutar el proyecto usando Run como aplicación SWT.

->

fin..

Algunos Errores comunes al ejecutar el proyecto: (without build paths)
Plugins están ubicados en ./eclipse/plugins

Agregar las clases (jar) “Libraries” al proyecto:
click derecho sobre la carpeta del proyecto selecionar “Properties”, dentro seleccionar “Java Build Path” en la pestaña “Libraries” click en el botón “add external JARs” ir a /eclipse/plugins

ClassNotFound IProgressMonitor,
Bug 122935 ” IProgressMonitor has moved and there don’t appear to be dependencies, Standalone SWT/JFace applications no longer need the big runtime jar file on their classpath (Equinox common is under 70KB).”

Solution: Agregar la librería JAR al proyecto: org.eclipse.equinox.common.

“Exception in thread “main” java.lang.NoClassDefFoundError: org/eclipse/core/commands/common/EventManager”
Sol: Add to build path org.eclipse.core.commands_3.2….jar
Agregar org.eclipse.core.commands_3.2….jar al build path Ver paso 4

referencias:
ejemplos jface windows
HelloWorldJface with embbeding Office Writer
Example Source Code JFace
DragAndDrop SWT example
Draks Blogger SWT PLUS

AWT, Swing, SWT, and JFace: A comparison of Java GUI libraries

Written by doutdex in: Eclipse,Java |

No Comments »

RSS feed for comments on this post. TrackBack URL


Leave a Reply

TheBuckmaker.com Wordpress Themes | Geld von Privat, Streaming Audio
футбол онлайн, live football, canlı izle, football streaming, football forum, football forums, canlı maç, football highlights, maç özeti, live football streaming, stream live football, free football streaming,