aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes To make JApplet repaint Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "To make JApplet repaint" Watch "To make JApplet repaint" New topic
Author

To make JApplet repaint

maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
On my JApplet I have one JTextArea. I also have variable counter. I would like to display different text on JTextArea for different values of variable counter.

For example, if counter is 5, to display "You are on 5th assignment".

I have written code for that, but my JAplet does not repaint. How to set that?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
That's impossible to say without seeing the code.
maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
Here is the code:


It works this way, I think I made it.

Greetings!
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Glad to hear you got it to work. Note that instead of "TestAplet.this.repaint()" you can just write "repaint()".
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2169
    
    7
You don't even need the repaint() method.

Swing components are smart enough to repaint themselves automatically when the value of a property (like setText) is changed.
maja neskovic
Ranch Hand

Joined: Apr 28, 2010
Posts: 134
OK. Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: To make JApplet repaint