SWT painting

From: it-inkom (it_inkom_at_hotmail.com)
Date: 01/25/05


Date: 24 Jan 2005 18:41:40 -0800

Hello!
I need a help.
I can't draw a line over a SWT control component as canvas.
Is it impossible? or i wrote a wrong code.

Take care
Alexander

display=new Display();
Shell shell=new Shell(display);
shell.setLayout(new RowLayout());
Canvas canvas=new Canvas(shell,SWT.NONE);
RowData data=new RowData(100,50);
canvas.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
canvas.setLayoutData(data);
shell.addListener(SWT.Paint,new Listener(){
public void handleEvent(Event event) {
event.gc.setForeground(new Color(display,new RGB(255,0,0)));
event.gc.drawLine(0,0,500,500);// try to draw a line over canvas
}
});
shell.pack();
shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch()) display.sleep();
}
display.dispose();



Relevant Pages

  • Re: Questions about drawing on Canvas
    ... I am attempting for the first time to do some drawing on a canvas. ... Why do you subclass from JPanel to draw rectangles, ... // TODO Find out what effect removing these LOC will have. ...
    (comp.lang.java.programmer)
  • Re: Questions about drawing on Canvas
    ... axes and then superimpose a line on the canvas as well, ... Why do you subclass from JPanel to draw rectangles, ... // TODO Find out what effect removing these LOC will have. ...
    (comp.lang.java.programmer)
  • Re: Should this be an object?
    ... then you might pass in the hDC or other canvas ... on which to draw itself. ... the object to draw itself, doesn't care how it does it, as long as ...
    (microsoft.public.vb.general.discussion)
  • Re: Newbie looking for info on basic graphics with Delphi.
    ... panel objuct on the main form. ... some of them draw on their parent's canvas. ... I think all of Windows' ...
    (comp.lang.pascal.delphi.misc)
  • Re: Newbie looking for info on basic graphics with Delphi.
    ... Do I need to use a canvas to draw? ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.lang.pascal.delphi.misc)