java - UI thread can not start after IDE changed -
i changed ide eclipse intellij idea. new 1 started complaining code.
public class controller { private oknoglowne frame; private menulistener menulisten = new menulistener(this); private tablistener tablistener = new tablistener(this); public oknoglowne getframe() { return frame; } public controller(){ eventqueue.invokelater(new runnable() { public void run() { try { frame = new oknoglowne(); frame.setvisible(true); //error frame.addmenulistener(menulisten); frame.addtablistener(tablistener); } catch (exception e) { e.printstacktrace(); } } }); } } so commented line. , add new line constructor of ui frame.
public oknoglowne() { jpanel.setvisible(true); } app start ui doesn't show more. idea create frame in different way eclispe. have switch.
main
public class runner { public static void main(string[] args) { new controller(); } }
this doesn't have ides. bet if ran 100 times in eclipse, or command line, you'd different results depending on how busy system is.
the reason aren't seeing jframe pop because you're using invokelater() instead of invokeandwait().
the invokelater() method returns, @ point you're in race condition: event thread display edt first, or main thread exit first? if main thread exits first, program exit before windows shown.
to prevent this, have use invokeandwait() instead of invokelater().
Comments
Post a Comment