Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To make JApplet repaint

 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's impossible to say without seeing the code.
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code:


It works this way, I think I made it.

Greetings!
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear you got it to work. Note that instead of "TestAplet.this.repaint()" you can just write "repaint()".
 
Rob Camick
Ranch Hand
Posts: 2582
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic