LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-18-2004, 03:15 PM   #1
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Rep: Reputation: 30
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
KDE Gnome Desktop Menu Edits (right click on desktop) jdier Linux - Software 11 08-03-2006 05:05 AM
java-gnome event bindings not working FC3 coccolli Fedora 0 02-21-2005 02:47 PM
Gnome 2.6.1: Single Click acts like Double Click Der_tolle_Emil Linux - Software 2 09-13-2004 08:59 AM
Editing GNOME menu that is displayed on a right click? coolamit78 Linux - Software 1 05-09-2004 02:44 PM
Debian/Gnome-Right-click menu arkamir Linux - Newbie 1 02-25-2004 08:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration