1

I am trying to display my output in Jtext Area.

while ((line1 = br1.readLine()) != null) {
    txt_output.append(line1+"\n");
    System.out.println(line1);
}

It gives me output once all the process finished. What want to show output execution line by line instead of all together.

please help me.....

StanislavL
  • 56,971
  • 9
  • 68
  • 98
Code Hungry
  • 3,930
  • 22
  • 67
  • 95

3 Answers3

1

One similar post in Stackoverflow, deals with concurrency using threads.

Refer this one: Dynamically refresh JTextArea as processing occurs?

Community
  • 1
  • 1
vaisakh
  • 1,041
  • 9
  • 19
0

You can possibly use the

textArea.setText();

method every time when you want the message to be printed. It automatically removes the previous text and writes the new one.

me_digvijay
  • 5,374
  • 9
  • 46
  • 83
  • Hi this is giving Only Last output i want all the output. – Code Hungry Mar 05 '12 at 09:16
  • The following method is very bad practice but you can try it for now int temp = 0; while ((line1 = br1.readLine()) != null) { if(temp==0){ txt_output.append(line1+"\n"); temp = 1; } if(temp==1) { System.out.println(line1); temp = 0; } } – me_digvijay Mar 05 '12 at 09:49
0

I know the following method is very bad practice but you can try it for now

int temp = 0;
while ((line1 = br1.readLine()) != null) {
if(temp==0){
   txt_output.append(line1+"\n");
   temp = 1;
 }
 if(temp==1) {
  System.out.println(line1);
temp = 0;
}
}
me_digvijay
  • 5,374
  • 9
  • 46
  • 83