?
Solved

Swing refresh textArea

Posted on 2004-11-02
1
Medium Priority
?
2,107 Views
Last Modified: 2008-02-01
Hi everybody,

I have a code like this:

public void disableResponse() {
   taResultArea.setText("Sending...");
   taResultArea.setEnabled(false);
   repaint();
}
      
public void sendRequest() {
   // Here I send something to a remote host
   // ...
   taResultArea.setText(response);
   taResultArea.setEnabled(true);
}

And in the action of the button I call both methods, first disableResponse, then sendRequest. Of course the above code doesn´t work, because between the disableResponse call and the sendRequest call I don't allow java to do the repaint work.

I thought the repaint call was enough to do the work... I was wrong. I don't want to put the management of the textArea in a thread. Is there a work around of this without the using of threads?

Best regards,

favelill
0
Comment
Question by:favelill
1 Comment
 
LVL 2

Accepted Solution

by:
tdisessa earned 400 total points
ID: 12476562
try this:

public void disableResponse() {
   taResultArea.setText("Sending...");
   taResultArea.repaint();
   taResultArea.update(taResultArea.getGraphics());
   taResultArea.setEnabled(false);
}
     
public void sendRequest() {
   // Here I send something to a remote host
   // ...
   taResultArea.setEnabled(true);
   taResultArea.setText(response);
   taResultArea.repaint();
}
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question