I am working on a swing application where in when a user clicks on a button, a new JFrame will be created.
But we have to restrict creation of another JFrame when user clicks on the button again.
Or can you atleast tell me how to constraint the user to the new frame..
Ex : when a JOptionpane is created, until and unless user closes it, he will not be able to click any where else..
That would be the GUI for your case. Note the "null" parameter that I passed. That parameter is used to tell Java which this OptionPane belongs to. In other words, which windows that can only be used again if the OptionPane gets a result. Usually, I just out "this" (the java keyword) in the place for the null, because I extend JPanel for some of my GUI related programs.
I am working on a swing application where in when a user clicks on a button, a new JFrame will be created.
But we have to restrict creation of another JFrame when user clicks on the button again.
Or can you atleast tell me how to constraint the user to the new frame..
Ex : when a JOptionpane is created, until and unless user closes it, he will not be able to click any where else..
Thanks,
Hari.
Don't open another JFrame but instead use a modal JDialog. This is specifically what they are for.