it-inkom Guest
|
Posted: Tue Jan 25, 2005 3:20 am Post subject: SWT painting |
|
|
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();
|
|