java - JTextField deletes String at newline instead of appending -


i trying create gui client application. bufferedreader's .readline() acting input stream. problem prints newlines , carriage-returns in console, once try append in textarea seems rewrite previous string. here's example code

 public class airlinesclient extends jframe implements actionlistener {     public static bufferedreader socketin = null;     public static printwriter socketout = null;     public static socket connection = null;     public static string breakline;     public static string command;     public airlinesclient() throws unknownhostexception, ioexception{         jpanel schpanel = new jpanel();         jbutton schedules  = new jbutton ("flight schedules");         jbutton pilots  = new jbutton ("pilots' shifts"); //mainframe           super.setsize(300, 400);           setlocationbyplatform(true);           setdefaultcloseoperation(exit_on_close);           setvisible(true); //adding schedulebutton's panel root frame           schpanel.setlayout(null);           getcontentpane().add(schpanel); //adding schedule button           schedules.setbounds(75, 10, 150, 50);           schedules.setvisible(true);           schpanel.add(schedules); //adding action on click           schedules.addactionlistener(new actionlistener() {             public void actionperformed(actionevent event) {                         jtextarea area = new jtextarea(20,20);                   jframe scheduleframe = new jframe("information");                   scheduleframe.setsize(800,400);                   scheduleframe.setdefaultcloseoperation(dispose_on_close);                   scheduleframe.setlocationrelativeto(null);                   scheduleframe.add(area);                                                  scheduleframe.setvisible(true);                      socketout.flush();                   socketout.println("1");                   area.append(breakline);              }         });  //adding pilots' shifts                  pilots.setbounds(75, 70, 150, 50);           pilots.setvisible(true);           schpanel.add(pilots);      }      public static void main(string[] args) throws unknownhostexception, ioexception {          new airlinesclient();          int port = 1234;         string host = "localhost";         connection = new socket(host,port);         socketin = new bufferedreader(new      inputstreamreader(connection.getinputstream()));         socketout = new printwriter(connection.getoutputstream(),true);          try{             system.out.println("successfully connected server!"); do{          //this prints output in console , ends when server sends $$$             while (!(breakline =socketin.readline()).equals("$$$")){                 system.out.println(breakline);             } //command input user keyboard testing purposes i'm using //a single socketout command(from actionlistener) send commands               }while(command!="0");         system.out.println("closing connection server!");     }catch(ioexception e){         e.printstacktrace();     } finally{            try{                if(socketin!=null) socketin.close();                if(socketout!=null) socketout.close();                if(connection!=null) connection.close();              }              catch(ioexception e){                system.err.println("socket not closed!");              }            }      }     @override     public void actionperformed(actionevent arg0) {      } } 


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -