java - Updating jTextArea in while loop -
i having problem writing/updating textarea. getting value readtemp function, , can see result after calling system out function, nothing appears in textarea. problem?
private void jbutton1actionperformed(java.awt.event.actionevent evt) { url temp; try { temp = new url("http://192.168.1.25/status.xml"); while (true) { system.out.println("homerseklet: " + readtemp(temp)); jtextarea1.append(readtemp(temp)); } } catch (malformedurlexception ex) { logger.getlogger(download.class.getname()).log(level.severe, null, ex); } }
correction: won't since infinite loop still block edt forever... nevermind!
your while loop really bad idea, if insist, can @ least give edt chance update ui dispatching append asynchronously:
swingutilities.invokelater(new runnable() { @override public void run() { jtextarea1.append(readtemp(temp)); } });
Comments
Post a Comment