Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » why no line display
why no line display [message #436375] Tue, 18 May 2004 08:41 Go to next message
Eclipse UserFriend
Originally posted by: hzjian1.hotmail.com

public Element()
{
Display display = new Display ();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
Composite parent = shell;
parent = new Composite(parent, SWT.NONE);
parent.setLayout(new GridLayout());
GC gc=new GC(parent,SWT.NONE);
Color color=new Color(display,10,10,10);
//gc.setBackground(color);
gc.drawLine(0,0,1000,1000);
gc.setLineStyle(SWT.LINE_SOLID);
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
//display.dispose ();

}
Re: why no line display [message #436390 is a reply to message #436375] Tue, 18 May 2004 13:59 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
This is what you want:

public class Main {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout());
parent.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
GC gc = new GC(parent, SWT.NONE);
gc.setLineStyle(SWT.LINE_SOLID);
gc.drawLine(0, 0, 1000, 1000);
gc.dispose();
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}

Grant

"hiray" <hzjian1@hotmail.com> wrote in message
news:c8ci04$hle$1@eclipse.org...
> public Element()
> {
> Display display = new Display ();
> Shell shell = new Shell(display);
> shell.setLayout(new GridLayout());
> Composite parent = shell;
> parent = new Composite(parent, SWT.NONE);
> parent.setLayout(new GridLayout());
> GC gc=new GC(parent,SWT.NONE);
> Color color=new Color(display,10,10,10);
> //gc.setBackground(color);
> gc.drawLine(0,0,1000,1000);
> gc.setLineStyle(SWT.LINE_SOLID);
> shell.pack();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> //display.dispose ();
>
> }
>
>
Re: why no line display [message #436391 is a reply to message #436375] Tue, 18 May 2004 13:59 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

They were erased by a subsequent paint refresh. To get things to show
you can't just paint at any time. You need to paint in a paint refresh.
Otherwise every time the window is shown, resized, exposed it will
repaint and wipe out your temporary changes. There is a paint listener
that can be added to a control to listen for paint requests, and then
you can paint at that time.


--
Thanks, Rich Kulp

Previous Topic:Font smoothing (anti aliasing) in Mac OS X (3.0M8)
Next Topic:DROP_DOWN style Combo
Goto Forum:
  


Current Time: Fri Apr 26 06:58:30 GMT 2024

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

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

Back to the top