Unable to hide a JFrame
I have a program which has to add menu's and stuff. for each "action" like adding a new menu, editing menu's, searching,... i let it open up a new frame for each.
The problem is, that i can't seem to find how to let the action listener for the "cancel" button hide the frame it is put on. My main frame opens up the frame "MenuAdd" where there's textfield for name and stuff and the Ok and cancel button. The frame hides when I click on the X (default close operation) but i can't seem to make it work with and event when i click on the button cancel.. anybody have any idea how to make this work?
Why use multiple JFrames? Why not use a dialog such as a JOptionPane or JDialog which could be a better fit?
One way to make the top-level window invisible is to call setVisible(false) to a reference to this window. This reference may be obtained (among other ways) by using SwingUtilities.getWindowAncestor method.
To import from a dropdown box?
Originally Posted by Fubarable
Or is that possible from JDialog or option pane as well?
I found that working with multiple panels and showing/hiding them was the best answer :) and this solves my problem :) and for just basic input like only a name or something using JDialog/JOptionPanes :) and that using a CardLayout was also the best answer. Thanks for the quick response