ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.