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.....

2
  • 1
    are you saying your console gets updated in the process and JTextArea not? Commented Mar 5, 2012 at 8:54
  • I am getting output in Jtextarea.My requirement is i want line by line output. Above lines gives me complete output once all finished. Commented Mar 5, 2012 at 8:58

3 Answers 3

1

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

Refer this one: Dynamically refresh JTextArea as processing occurs?

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

Hi this is giving Only Last output i want all the output.
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; } }
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;
}
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.