views:

142

answers:

1

i've made a menu bar with netbeans.

in the menubar i've got

file >exit
Help >Help F1
     >about

the problem is i don't know how to link up either help or about to another frame that has everything i want the user to see.

can someone please tell me how to go to a new frame once eiher help or about is clicked?

thanks

+3  A: 

For About, you would typically use a modal dialog, i.e. a JOptionPane - using those is pretty straightforward. For Help, you don't want a modal dialog, but a new separate JFrame. But you don't have to "go to" it - just create it and call show() - that's all you need to do. Like modern GUIs in general, Swing does not have an explicit control flow through or between masks. The GUI is shown, and only when the user interacts with it is your code in the various event handlers called.

Michael Borgwardt
thanks.here is what i have achieved for help.in main main.java help helpForm - new help(); helpForm.setVisible(true);in calc.java private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) { new help().setVisible(true); when i run the application it says compiled with errors. do you know what i could be? it doesn't say anything else just sys 1 or more projects were compiled with errors
Tuffy G
Netbeans should underline compiler errors in your source code even while you type and additionally display them in the Tasks view. You have to fix those before it makes sense to try and run the application. They won't just magically go away when you ignore them.
Michael Borgwardt
fixed it lol. i put - instead of =. dam fat fingers. lol.thanks for your help.
Tuffy G
This answer is basically correct, but I would encourage you to use the NetBeans platform classes, instead of raw swing. One concrete example of that would be to use a NotifyDescriptor (http://bits.netbeans.org/dev/javadoc/org-openide-dialogs/org/openide/NotifyDescriptor.html) like NotifyDescriptor.Message instead of JOptionPane. If the NB platform switches to a different technology base (unlikely), you would not be required to change your code to use that new technology.
vkraemer
What kind of "different technology" could NB possibly switch to that would not support Swing, which is part of the Java standard API? Unless you're writing a Netbeans plugin, I would avoid tying myself needlessly to it.
Michael Borgwardt