Java: append to JTextPanel not working inside ActionListener -
i working on program work queries logs , posts results in textarea box. can append box outside action listener search, not within.
i have added system out lines append text , shows being received not posting. internal frame.
any pointing me fixing appreciated.
package net.fedson; import javax.swing.*; import java.awt.*; class searchframe { private textpanel textpanel; private formpanel formpanel; private string user; private string password; private string logs; public jinternalframe searchframe() { jinternalframe mboxframe = new jinternalframe("search", true, true, true, true); mboxframe.setlayout(new borderlayout()); textpanel = new textpanel(); //btn = new btnpanel(); //toolbar = new toolbar(); formpanel = new formpanel(); formpanel.setformlistener(new formlistener() { @override public void formeventoccured(formevent e) { string email = e.getemail(); string = e.getextra(); string direction = e.getdirection(); string time = e.gettime(); configgetpropertyvalues properties = new configgetpropertyvalues(); try { properties.getpropertyvalues(); user = properties.getuser(); password = properties.getpassword(); } catch(exception e1){ system.out.println("exception: " + e1); }finally { textpanel.clearpanel(); //textpanel.appendtext("starting search\n"); search s = new search(email, extra, direction, time, user, password); logs = s.startsearch(); } //system.out.println(logs); textpanel.appendtext(logs); //doesnt work } }); textpanel.appendtext("outside listener"); //works mboxframe.add(formpanel, borderlayout.west); //add(toolbar, borderlayout.north); mboxframe.add(textpanel, borderlayout.center); //add(btn, borderlayout.south); mboxframe.setsize(800, 600); mboxframe.setdefaultcloseoperation(jframe.hide_on_close); mboxframe.setvisible(true); return mboxframe; } public void writetext(string text){ textpanel.appendtext(text); } }
Comments
Post a Comment