Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Display, Graphics and GTK
Display, Graphics and GTK [message #444641] Mon, 18 October 2004 16:51 Go to next message
Stef van Dijk is currently offline Stef van DijkFriend
Messages: 31
Registered: July 2009
Member
Sorry if this is a dumb question, but I'm relatively new to working with
GTK.
Is it actually possible to create a graphics on the display and draw to it?
That is, can I draw directly to the desktop?

I tried writing the following very simple app, but nothing appears on the
screen. Am I missing something?
Note that the same app works fine on WinXP.

Stef

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;

public class TestDisplayGraphics {

public static void main(String[] args) {
Display d = new Display();
GC gc = new GC(d);

gc.setBackground(d.getSystemColor(SWT.COLOR_GREEN));
gc.fillRectangle(100,100,200,200);
gc.setBackground(d.getSystemColor(SWT.COLOR_RED));
gc.fillRectangle(400,400,200,200);

gc.dispose();

System.out.println("Test complete");
}
}
Re: Display, Graphics and GTK [message #444676 is a reply to message #444641] Wed, 20 October 2004 13:22 Go to previous messageGo to next message
Stef van Dijk is currently offline Stef van DijkFriend
Messages: 31
Registered: July 2009
Member
Does anyone know the answer to this please?

Stef

"Stef van Dijk" <not-me@not-here.com> wrote in message
news:cl0s0u$utc$1@eclipse.org...
> Sorry if this is a dumb question, but I'm relatively new to working with
> GTK.
> Is it actually possible to create a graphics on the display and draw to
it?
> That is, can I draw directly to the desktop?
>
> I tried writing the following very simple app, but nothing appears on the
> screen. Am I missing something?
> Note that the same app works fine on WinXP.
>
> Stef
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.graphics.GC;
> import org.eclipse.swt.widgets.Display;
>
> public class TestDisplayGraphics {
>
> public static void main(String[] args) {
> Display d = new Display();
> GC gc = new GC(d);
>
> gc.setBackground(d.getSystemColor(SWT.COLOR_GREEN));
> gc.fillRectangle(100,100,200,200);
> gc.setBackground(d.getSystemColor(SWT.COLOR_RED));
> gc.fillRectangle(400,400,200,200);
>
> gc.dispose();
>
> System.out.println("Test complete");
> }
> }
>
>
Re: Display, Graphics and GTK [message #444689 is a reply to message #444676] Wed, 20 October 2004 14:34 Go to previous message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
Hi Stef,

1. We released a fix in HEAD for GTK. It should work in the next nigthly
build N20041021
2. Your example needs to run the event loop

With 1. and 2. you should be able to get going...

Chris
Previous Topic:java spider help
Next Topic:browser widget - remove border
Goto Forum:
  


Current Time: Thu Oct 29 10:08:33 GMT 2020

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

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

Back to the top