java - How to create JFrame in the same thread so that it blocks? -
for debug purposes, need draw image on screen in simple window.
swing handles it's events in separate message loop thread. means if following:
while(true) { //get screenshot bufferedimage screenshot = mswindow.screenshot(); //create jframe jframe frame = new jframe(); container main = frame.getcontentpane(); //this layout should force jlabel large window, right? main.setlayout(new gridlayout(1,1)); //create jlabel display screenshot jlabel label = new jlabel(new imageicon(screenshot)); main.add(label); frame.pack(); frame.setvisible(true); //delay allways when meddling dangerous things thread.sleep(2000); }
... end many many jframes.
i used use jdialog blocking , stops thread until press ok:
joptionpane.showmessagedialog(null, scrollpane, message, javax.swing.joptionpane.information_message);
this has flaw though - can't see debug window on taskbar. sometimes, it's hard find window ended up. why want switch jframe.
my question straight this: how make current thread wait until jframe closed?
how create jframe in same thread blocks?
use modal jdialog.
joptionpane.showmessagedialog(null, scrollpane, message, javax.swing.joptionpane.information_message);
this has flaw though - can't see debug window on taskbar.
don't use null dialog owner. make sure specify owner jframe. whenever click on taskbar icon frame , child dialog both show up.
Comments
Post a Comment