I'm programming my first java App, I wanna create a GUI, which allow to draw different Plan. As close as possible to this representation :
My implementation is based on SWT.
For drawing Nodes and Edges, I used addPaintListener()
method from the class Canvas.
But i have following problem, the method paintControl()
is called infinitely times, redrawing every time.
I ask myself if there is a way to avoid it, or maybe a better way to draw a plan in Java.
Can someone of you suggest me a best way to draw diagram and edge in Java
Canvas canvas = new Canvas(composite, SWT.ALL);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Rectangle rect=new Rectangle(0, 0, 60, 30);
e.gc.drawRectangle(rect);
}
});