java - Can not print in Text area from same class? -
java - Can not print in Text area from same class? -
i want print in text area named arena
. calling append
method same class no luck far. how print string in text area??
public class chat_window extends javax.swing.jframe implements runnable { public static datainputstream in = null; public static printstream out = null; private static socket cs = null; private static bufferedreader zz; private static boolean live = true; public chat_window() { initcomponents(); } public static void main(string args[]) { java.awt.eventqueue.invokelater(new runnable() { @override public void run() { chat_window w=new chat_window(); w.setvisible(true); } }); seek { cs = new socket("localhost", 3333); out = new printstream(cs.getoutputstream()); zz = new bufferedreader(new inputstreamreader(system.in)); in = new datainputstream(cs.getinputstream()); } grab (exception ex) { system.out.println(ex); } if (cs != null && out != null && in != null) { seek { new thread(new chat_window()).start(); while (alive) { out.println(zz.readline().trim()); } out.close(); in.close(); cs.close(); } grab (exception error) { system.out.println(error); } } } @override public void run() { seek { while ((m = in.readline()) != null) { **arena.append(m);** //this line doesnt work system.out.println(m); } } grab (exception e) { system.out.println(e); } } // variables declaration private java.awt.textarea arena; private java.awt.textarea textarea2; private java.awt.textarea usrchat; // end of variables declaration }
try replace arena.settext(arena.gettext()+"\n"+m);
or arena.settext(arena.gettext()+m);
if don't want add together new line in between :)
java textarea
Comments
Post a Comment