• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to refresh / repaint a JLabel  RSS feed

 
Joe Lemmer
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I wonder if anyone can help me... Also, I have a question about Java:

I've made a simple GUI with a a JTextField, a JButton and a JLabel.
The JLabel shows a string plus a variable:



What I want to do is enter a number into the TextField then press the button and have whatever is in the field added onto a variable 'cnt'. Obviously the JLabel 'count' needs to show this new figure. I have included the println statement in the class in order to see that the code above it worked and it does, so the variable 'cnt' is being added to. I just need to be able to get the JLabel to show this. All help much appreciated.

cheers

Joe

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the JLabel you construct with the lineisn't the same JLabel that's already added to the GUI, so you never see it. Read the API for a method that allows you to (hint, hint) set the text of an existing JLabel.
 
Joe Lemmer
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WooooHoooo!!! It really is beautiful!

Thanks for the help DB ;-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!