[Java-gnome-developer] Assertion failure while drawing on DrawingArea
Brought to you by:
afcowie
From: Jaime <re...@sa...> - 2004-12-12 14:09:58
|
Hi folks. I've tried to write a simple little program to draw on a DrawingArea, but without success. I get the following assertion failure at runtime: (java-gnome:2393): Gdk-CRITICAL **: file gdkdraw.c: line 338 (gdk_draw_point): assertion `GDK_IS_DRAWABLE (drawable)' failed Could anyone please tell me where I'm going wrong? In fact, a pointer to any example code which successfully draws onto a DrawingArea would be just as good! Thank you, Jaime :-) <snip> package drawingAreaTest; import org.gnu.gtk.DrawingArea; import org.gnu.gtk.Gtk; import org.gnu.gtk.Window; import org.gnu.gtk.WindowType; import org.gnu.gtk.event.ExposeEvent; import org.gnu.gtk.event.ExposeListener; import org.gnu.gtk.event.LifeCycleEvent; import org.gnu.gtk.event.LifeCycleListener; public class Test { DrawingArea area = null; Window window; Test() { window = new Window(WindowType.TOPLEVEL); window.setTitle("Drawing Area Example"); window.addListener(new LifeCycleListener() { public void lifeCycleEvent(LifeCycleEvent event) { } public boolean lifeCycleQuery(LifeCycleEvent event) { if (event.isOfType(LifeCycleEvent.Type.DESTROY) || event.isOfType(LifeCycleEvent.Type.DELETE)) { Gtk.mainQuit(); } return true; } }); area=new DrawingArea(); window.add(area); area.addListener(new ExposeListener() { public boolean exposeEvent(ExposeEvent event) { System.out.println("Expose event: "+window.getWindow()); window.getWindow().drawPoint(20, 20); return false; } }); window.showAll(); System.out.println("Should be printed before expose event"); } public static void main(String[] args) { Gtk.init(args); new Test(); Gtk.main(); } } </snip> |