Reputation: 41
I'm using CHARVA (ncurses-like Swing) and I have a problem.
Because charva is very similar to Swing, I think the solution for Swing is the same to charva.
I'm developing an application that call a JFrame
-extended class, get
its return code and shows other JFrame
windows depending on return code.
It's like :
public static void main() {
MainFrame mainframe=new MainFrame();
mainframe.show();
switch (mainframe.returncode) {
case "generalsetting": Frame1 frame1=new Frame1;
frame1.show();
break;
case "usersetting": Frame2 frame2=new Frame2;
frame2.show();
break;
etc. But when I do:
mainframe.show();
The program does not wait until mainframe is closed/hidden, but continue on the "switch", the return code is not initialized and crashes my program.
There is a way to have a "blocking" show()
?
Upvotes: 2
Views: 2035
Reputation: 22233
there is a way to have a "blocking" show()?
Yes. You can make MainFrame
extend JDialog
instead of JFrame
and make it modal:
class MainFrame extends JDialog {
//code...
}
System.out.println("Before");
MainFrame d = new JDialog();
d.setModal(true);
d.setVisible(true);
System.out.println("After");
Upvotes: 3
Reputation: 5608
If you want to perform a blocking call, you can try using a modal JDialog
instead of a JFrame
: simply use true
for modal
parameter in its constructor (see JDialog)
Although, I don't know Charva, but JFrame.show()
is deprecated since Java 1.5 (you shall use setVisible(true)
instead).
Upvotes: 4