Reputation: 115
I want to extend my JFrame
Form ... with one JDialog
form (I want to connect with frame, I want in the menu-bar when someone click to the HELP (from the menu) will show the new dialog box. I do not want to use JOptionPane
for this use.
I made in to the program menu with Help menu item, now on the actionPerformed
will something write.
new help(this, true, ).setVisible(true);
Something this but I don't remember - what is correct?
Upvotes: 1
Views: 3525
Reputation: 109815
this
from new help(this, true, ).setVisible(true);
could be missinterpreted by another this
in rest of your code
create local variable for JFrame
and JDialog
, use title
and Modal/ModalityType
if is required, e.g. new JDialog(myFrame, ....)
create only one instace of JDialog
, change DefaultCloseOperations
to HIDE_ON_CLOSE
(then only) call myDialog.setVisisble(true)
delayed inside invokeLater()
(from JMenuItems event
)
Upvotes: 1
Reputation:
Why not using javax.swing.JOptionPane
? It provides you all you need to show dialogs and prompt the user for inputs.
JOptionPane p = new JOptionPane();
// init p
p.setVisible(true);
Upvotes: 0