java - Process freeze( or crash) because of JFrame -


this code.

    processbuilder process = new              processbuilder(mypath);     process prp1 = process.start();      final jframe frmscanner;     frmscanner = new jframe();     frmscanner.settitle("updater");     frmscanner.setresizable(false);     frmscanner.setbounds(100, 100, 370, 300);     frmscanner.setdefaultcloseoperation(jframe.exit_on_close);       label1.setbounds(100,50,200,50);     final jbutton startbutton = new jbutton("start!!!");     startbutton.setbounds(50, 140, 100, 50);       jpanel p1 = new jpanel(null);     p1.setbackground(new color(255,255,255));      p1.add(startbutton);     p1.add(stopbutton);     frmscanner.add(p1);     frmscanner.setvisible(true); 

my process task collecting data project's hardware text file.

i have tested , found text file can collect data 1kb , process hang because of frmscanner.setvisible(true); .

if manually run process process can collect data more 1kb. how can solve this?

you need ui related stuff (jframe creation, etc.) on special separate thread called edt. take @ docs: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html .


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -