Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » doubts about draw2d
doubts about draw2d [message #464343] Mon, 21 November 2005 20:40 Go to next message
Eclipse UserFriend
Originally posted by: hdsn82.yahoo.com.br

When I execute the code bellow, if I minimize the window run the figure
dissappear...Do you guys know why is it happen? What code changes should I
do in this case?
Thanks a bunch!

import java.awt.Color;
import org.eclipse.draw2d.ChopboxAnchor;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class DrawExample {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Drawing Example");



Canvas canvas = new Canvas(shell, SWT.NULL);

canvas.setSize(600, 400); //espaço interno onde está inserido o desenho
canvas.setLocation(-40, -30);
//canvas.addPaintListener(this);
canvas.setVisible(true);
shell.open();
shell.setSize(600, 400); //tamanho da tela que contém o desenho

GC gc = new GC(canvas);
gc.drawArc(200,156,150,130,180, -180);
//3º - largura da elipse,
//4º - altura da elipse

gc.drawArc(200,156,150,130,-180, 180);
gc.drawText("lk;fasjdfl;sda", 220,190);

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.getCurrent().dispose();
}
}
Re: doubts about draw2d [message #464347 is a reply to message #464343] Mon, 21 November 2005 21:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Neto <hdsn82@yahoo.com.br> wrote:
> When I execute the code bellow, if I minimize the window run the
> figure dissappear...Do you guys know why is it happen? What code
> changes should I do in this case?
> Thanks a bunch!
>
[snip]

Ask this question in the GEF newsgroup. news:eclipse.tools.gef
--
Sunil
Re: doubts about draw2d [message #464372 is a reply to message #464343] Tue, 22 November 2005 09:21 Go to previous message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

As far as I can see you need to put your drawing code into a paint
listener otherwise it will only be executed once.

Regards,
Friederich

Neto wrote:
> When I execute the code bellow, if I minimize the window run the figure
> dissappear...Do you guys know why is it happen? What code changes should
> I do in this case?
> Thanks a bunch!
>
> import java.awt.Color;
> import org.eclipse.draw2d.ChopboxAnchor;
> import org.eclipse.draw2d.Figure;
> import org.eclipse.draw2d.LightweightSystem;
> import org.eclipse.draw2d.PolygonDecoration;
> import org.eclipse.draw2d.PolylineConnection;
> import org.eclipse.draw2d.XYLayout;
> import org.eclipse.draw2d.geometry.PointList;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.GC;
> import org.eclipse.swt.widgets.Canvas;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> public class DrawExample {
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setText("Drawing Example");
>
>
> Canvas canvas = new Canvas(shell, SWT.NULL);
>
> canvas.setSize(600, 400); //espaço interno onde está inserido o desenho
> canvas.setLocation(-40, -30);
> //canvas.addPaintListener(this);
> canvas.setVisible(true);
> shell.open();
> shell.setSize(600, 400); //tamanho da tela que contém o desenho
>
> GC gc = new GC(canvas);
> gc.drawArc(200,156,150,130,180, -180);
> //3º - largura da elipse,
> //4º - altura da elipse gc.drawArc(200,156,150,130,-180, 180);
> gc.drawText("lk;fasjdfl;sda", 220,190);
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.getCurrent().dispose();
> }
> }
>


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Previous Topic:Changing Behavior of Default Window Buttons
Next Topic:how to the set color of a tree row ?
Goto Forum:
  


Current Time: Mon Dec 09 18:26:56 GMT 2019

Powered by FUDForum. Page generated in 0.02484 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top