| elementary draw2d program doesn't work [message #643944] |
Wed, 08 December 2010 13:40  |
Carlo Salinari Messages: 66 Registered: October 2010 |
Member |
|
|
Hi,
I'm trying to visualize a rectangle with draw2d. Can you tell me why
this isn't working?
package test;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.RectangleFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Test extends Shell {
public static void main(String args[]) {
Display d = new Display();
Shell shell = new Shell(d);
Canvas canvas = new Canvas(shell, SWT.NONE);
LightweightSystem lws = new LightweightSystem(canvas);
IFigure contents = new Figure();
contents.setLayoutManager(new XYLayout());
IFigure figure = new RectangleFigure();
figure.setForegroundColor(ColorConstants.cyan);
contents.add(figure, new Rectangle(100, 100, 200, 300));
lws.setContents(contents);
shell.setText("draw2d");
shell.open();
while (!shell.isDisposed())
while (!d.readAndDispatch())
d.sleep();
}
}
|
|
|