[Java-gnome-developer] A little Problem
Brought to you by:
afcowie
From: Ralph H. <ra...@gm...> - 2005-05-27 05:10:37
|
Hi, sorry for my bad english! I have a problem with this little program. I will split the program into and control Class. I have create a litlle gui with glade. When i start the program i become an Exception, dont understand this... :( Exception in thread "main" java.lang.NullPointerException at org.gnu.gtk.Button.fireButtonEvent(Button.java:293) at org.gnu.gtk.Button.handleEnter(Button.java:307) at org.gnu.gtk.Gtk.gtk_main(Native Method) at org.gnu.gtk.Gtk.main(Gtk.java:55) at presentation.programm.Example.main(Example.java:26) Exception in thread "main" java.lang.NullPointerException at org.gnu.gtk.Button.fireButtonEvent(Button.java:293) at org.gnu.gtk.Button.handleLeave(Button.java:311) at org.gnu.gtk.Gtk.gtk_main(Native Method) at org.gnu.gtk.Gtk.main(Gtk.java:55) at presentation.programm.Example.main(Example.java:26) This Exception come when i move the mouse over the button. Greets Ralph Oh, thanks for the TreeView Guide. This was very helpful for me!!! -------------- Example.java -------------------- package presentation.programm; import org.gnu.gtk.*; import org.gnu.glade.*; import org.gnu.gnome.Program; import control.ControlExample; public class Example{ Button button; ControlExample control; public Example() { try { LibGlade glade = new LibGlade("glade/2.glade", this); button = (Button) glade.getWidget("button1"); } catch (Exception e) { } button.addListener(getControl()); } public ControlExample getControl(){ return control; } public static void main(String[] args) { Program.initGnomeUI("Hello", "0.1", args); new Example(); Gtk.main(); } } -------------- End Example.java -------------------- -------------- ControlExample.java -------------------- package control; import org.gnu.gtk.event.*; public class ControlExample implements ButtonListener { public ControlExample() { } public void buttonEvent(ButtonEvent event) { System.out.println("Hello"); } } -------------- End ControlExample.java -------------------- -------------- 2.glade -------------------- <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <requires lib="gnome"/> <widget class="GtkWindow" id="window1"> <property name="visible">True</property> <property name="title" translatable="yes">window1</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <child> <widget class="GtkButton" id="button1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label">gnome-stock-about</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">False</property> </widget> </child> </widget> </glade-interface> -------------- End 2.glade -------------------- -- Ralph Henneberger <ra...@gm...> |