LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   java-gnome Menu click event(nothing happens) (https://www.linuxquestions.org/questions/programming-9/java-gnome-menu-click-event-nothing-happens-232223/)

rmanocha 09-18-2004 03:15 PM

java-gnome Menu click event(nothing happens)
 
Hi,
I have recently found an urge to learn GUI designing and programming. Since I am a java coder(for the most part) and since I love gnome, i started off with using the java-gnome bindings to develop some basic and simple GUI's using java.
I started with the tutorial given on the java-gnome site.
I got to the second example code and copied it over. it compiles and executes fine...but clicking on quit in the file menu or clicking on help/about do not show/execute anything..even though looking at the code..they should.
I am attaching the code here:
Code:

import org.gnu.gnome.About;
import org.gnu.gnome.App;
import org.gnu.gnome.Program;
import org.gnu.gnome.UIInfo;
import org.gnu.gtk.ButtonsType;
import org.gnu.gtk.DialogFlags;
import org.gnu.gtk.Gtk;
import org.gnu.gtk.MessageDialog;
import org.gnu.gtk.MessageType;
import org.gnu.gtk.event.LifeCycleEvent;
import org.gnu.gtk.event.LifeCycleListener;
import org.gnu.gtk.event.MenuItemEvent;
import org.gnu.gtk.event.MenuItemListener;

public class Second implements MenuItemListener {
        private App app = null;
        public static final String appVersion = "0.1";

        public Second() {
                createMainWindow();
                createMenus();
                app.showAll();
        }

        private void createMainWindow() {
                app = new App("Second", "Second App");
                app.setDefaultSize(200, 200);
                app.addListener(new LifeCycleListener() {
                        public void lifeCycleEvent(LifeCycleEvent event) {}
                        public boolean lifeCycleQuery(LifeCycleEvent event) {
                                Gtk.mainQuit();
                                return false;
                        }
                });
        }

        private void createMenus() {

                UIInfo fileMenu[] = {
                        UIInfo.newItem("New Window", "Open a new application window", this),
                        UIInfo.separator(),
                        UIInfo.openItem(this),
                        UIInfo.saveItem(this),
                        UIInfo.saveAsItem(this),
                        UIInfo.separator(),
                        UIInfo.closeItem(this),
                        UIInfo.quitItem(new MenuItemListener() {
                                public void menuItemEvent(MenuItemEvent event) {
                                        fileExit();
                                }
                        }),
                        UIInfo.end()
                };

                UIInfo editMenu[] = {
                        UIInfo.undoItem(this),
                        UIInfo.redoItem(this),
                        UIInfo.separator(),
                        UIInfo.cutItem(this),
                        UIInfo.copyItem(this),
                        UIInfo.pasteItem(this),
                        UIInfo.separator(),
                        UIInfo.findItem(this),
                        UIInfo.findAgainItem(this),
                        UIInfo.replaceItem(this),
                        UIInfo.propertiesItem(this),
                        UIInfo.end()
                };

                UIInfo moveMenu[] = {
                        UIInfo.item("_Up", "Move selection up", this),
                        UIInfo.item("D_own", "Move selection down", this),
                        UIInfo.end()
                };

                UIInfo helpMenu[] = {
                        UIInfo.help("second"),
                        UIInfo.aboutItem(new MenuItemListener() {
                                public void menuItemEvent(MenuItemEvent event) {
                                        helpAbout();
                                }
                        }),
                        UIInfo.end()
                };

                UIInfo mainMenu[] = {
                        UIInfo.subtree("_File", fileMenu),
                        UIInfo.subtree("_Edit", editMenu),
                        UIInfo.subtree("_Move", moveMenu),
                        UIInfo.subtree("_Help", helpMenu),
                        UIInfo.end()
                };

                app.createMenus(mainMenu);
        }

        public void helpAbout() {
                String title = "Second App";
                String version = "Version " + appVersion;
                String license = "GPL";
                String[] authors = { "The Java-GNOME team" };
                String comments = "This example is a part of the Java-GNOME tutorial";
                String[] documenters = { "Many people" };
                String translator = "";
                About about =
                        new About(title, version, license, comments, authors, documenters, translator, null);
                about.show();
        }

        public void fileExit() {
                Gtk.mainQuit();
        }

        public void menuItemEvent(MenuItemEvent event) {
                MessageDialog dialog = new MessageDialog(app, DialogFlags.MODAL,
                                                                                                MessageType.INFO, ButtonsType.OK,
                                                                                                "Not implemented", false);
                dialog.run();
                dialog.destroy();
        }

        public static void main(String[] args) {
                Program.initGnomeUI("Second", Second.appVersion, args);
                new Second();
                Gtk.main();
        }
}

I would really appreciate if someone could tell me what is going on. I did leave a message on the java-gnome mailing list but i got no replies from there either.
Thanks


All times are GMT -5. The time now is 07:31 PM.