Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    18
    Rep Power
    0

    Default Window overwriting messages and a few questions

    Hi, I have code that creates a window and shows a couple of lines of text that I send to an JTextArea. The problem is that each line of text is overwritten by each new line that comes. So in the end, I finish with only that last line of code being showed up. Here is the code:
    Java Code:
    JFrame jframe = new JFrame ();
        jframe.setVisible (true);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        JTextArea ta = new JTextArea(20,40);  
        jframe.getContentPane().add(new JScrollPane(ta));  
        jframe.pack();
        if (args[2].equals ("bi")) {
          try {
            FileReader fr = new FileReader ("indice.txt");
            BufferedReader br = new BufferedReader (fr);	
            System.out.println ("O arquivo-indice existe!");
            ta.setText ("O arquivo-indice existe!");
            if (fm.checkFileList ()) {  
              System.out.println ("Arquivo indice nao foi modificado. Nada a fazer");  
    	  ta.setText ("Arquivo indice nao foi modificado. Nada a fazer");
            }
            else {
              System.out.println ("Arquivo índice foi modificado. Atualizando arquivo índice de reserva: "); 
              ta.setText ("Arquivo índice foi modificado. Atualizando arquivo índice de reserva: "); 
              fm.printFileList();
            }
    If I execute until here, only one of the
    Java Code:
    ta.setText
    inside the if/else clause will be executed.

    So what I can do to keep all the messages being showed up?

  2. #2
    camickr is online now Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: Window overwriting messages and a few questions

    Don't use the setText() method. Instead use the append(...) method.

  3. #3
    Join Date
    Dec 2009
    Posts
    18
    Rep Power
    0

    Default Re: Window overwriting messages and a few questions

    Quote Originally Posted by camickr View Post
    Don't use the setText() method. Instead use the append(...) method.
    Thanks!

Similar Threads

  1. Rush hour: array overwriting
    By MatthijsJava in forum Advanced Java
    Replies: 2
    Last Post: 01-29-2013, 09:35 AM
  2. File overwriting?
    By OllyHal in forum New To Java
    Replies: 1
    Last Post: 02-08-2012, 09:11 PM
  3. Writing data to file, but not overwriting it.
    By Renxx in forum New To Java
    Replies: 3
    Last Post: 12-10-2011, 10:14 PM
  4. Array overwriting data
    By hobo in forum New To Java
    Replies: 7
    Last Post: 10-27-2010, 01:29 PM
  5. Replies: 0
    Last Post: 03-05-2010, 07:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •