java - How To Make A JFrame/JPanel "Modal" So No Input Will Continue Until The Window Is Closed Or Button Pushed? -
i had question here , suggested me make program "modal" in order block program running next line , "pausing" program when popup happened. have tried it, not understand how works 100%.
here's code tried test with:
import javax.swing.*; import java.awt.*; public class test { public static void main(string[] args) { jframe thedog = new jframe(); thedog.setsize(200,200); thedog.setvisible(true); new jdialog(thedog,"thetitle", dialog.modalitytype.application_modal); system.out.println("hello"); } }
when jpanel box pops up, should "halt" program until action taken there. example, want have button push based on picture. i'm looking custom jpanel/jframe, not using joptionpane input dialog or that.
when run code above, system.out.println runs no matter what, if haven't closed dialog box, it's program ignores pop up. how can halt , wait user action before taking next move?
here's previous question had asked suggestions given: how halt current programs "progress" @ jpanel/jframe pop up?
you need make dialog visible before block...
jdialog dialog = new jdialog(thedog,"thetitle", dialog.modalitytype.application_modal); dialog.setvisible();
windows in swing not visible default
have @ how make dialogs more details
Comments
Post a Comment