Graphic Context in View [message #447116] |
Wed, 08 December 2004 20:13 |
Eclipse User |
|
|
|
Originally posted by: duc_niit.yahoo.co.uk
I have a view and I wanna use graphic context to drawing a line.Here is my
code but I see nothing.Can anybody tell me why ?.Thanks a lot
public void createPartControl(Composite parent)
{
display = parent.getDisplay();
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setBackground(new
org.eclipse.swt.graphics.Color(org.eclipse.swt.widgets.Displ ay.getDefault(),
255, 255, 255));
form.setSize(800,600);
GC gc = new GC(form.getDisplay(),SWT.NONE);
gc.drawLine(100,100,500,500);
gc.dispose();
}
public void setFocus()
{
form.setFocus();
}
public void dispose() {
toolkit.dispose();
super.dispose();
}
}
|
|
|
|
|
Re: Graphic Context in View [message #447220 is a reply to message #447116] |
Thu, 09 December 2004 18:56 |
Ivan Markov Messages: 61 Registered: July 2009 |
Member |
|
|
1. You are trying to draw directly on the desktop instead of on the control
which the view wraps. (form.getDisplay())
2. As the other poster mentioned, the way you do it (not in PaintListener)
will result in the fact that if your control got obscured by another window,
it will not repaint itself properly.
"mylove" <duc_niit@yahoo.co.uk> wrote in message
news:cp7na6$f5h$1@www.eclipse.org...
> I have a view and I wanna use graphic context to drawing a line.Here is my
> code but I see nothing.Can anybody tell me why ?.Thanks a lot
>
> public void createPartControl(Composite parent)
> {
> display = parent.getDisplay();
>
> toolkit = new FormToolkit(parent.getDisplay());
> form = toolkit.createScrolledForm(parent);
> form.setBackground(new
>
org.eclipse.swt.graphics.Color(org.eclipse.swt.widgets.Displ ay.getDefault(),
> 255, 255, 255));
> form.setSize(800,600);
>
> GC gc = new GC(form.getDisplay(),SWT.NONE);
> gc.drawLine(100,100,500,500);
> gc.dispose();
> }
>
> public void setFocus()
> {
> form.setFocus();
> }
>
> public void dispose() {
> toolkit.dispose();
> super.dispose();
> }
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.02695 seconds