// create default MenuBar for all windows
JMenuBar menuBar = new JMenuBar();
JMenu file = new JMenu("File"); // TODO i18n
menuBar.add(file);
file.add(new JMenuItem(new CloseWindowAction()));
MainFrame.getInstance().setJMenuBar(menuBar); // [1] comment
this for tests
app.setDefaultMenuBar(menuBar);
}
}
public class CloseWindowAction extends AbstractAction {
public CloseWindowAction() {
putValue(NAME, "Close"); // TODO i18n
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
}
public void actionPerformed(ActionEvent e) {
// TODO implement method CloseWindowAction.actionPerformed()
System.out.println("Close window action performed.");
}
}
And now where is problem. If I launch application with line [1]
commented, application didn`t respond to Cmd-W keystroke. Once I added
that line, action is called after pressing Cmd-W. But there is no
visual feedback for user. I can only see in log my message. So my
questions are:
1) Is it really nessecary necessary to add JMenuBar to window? Yes, I
know it should be because of other OS`s. But I make this application
only for Mac OS X, so I don`t care.
2) Shouldn`t be there some visual feedback like without using default
menubar? If it is only bug, i will report it. But maybe I am doing
something wrong. Thats the reason I ask first here.
Marian Bouček
Java programmer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden