The moose likes Swing / AWT / SWT and the fly likes Change jLabel properties in loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Change jLabel properties in loop" Watch "Change jLabel properties in loop" New topic

Change jLabel properties in loop

Thomas Feld

Joined: Sep 08, 2009
Posts: 3
Hi, I'm new here, so I'm not sure where to post this...

Basically I have a bunch of jlabels, who's properties I want to change in a loop.
Is there a simple way to iterate through the jlabels and set properties in the loop?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38472
You would have to put them into an array or Collection to iterate them in a loop.

And welcome to JavaRanch
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268

We have a forum dedicated for Swing. I will move this thread there for you.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Thomas Feld

Joined: Sep 08, 2009
Posts: 3
Thanks, I know i have to put them in an array, though I'm not sure how to call them from there. What datatype would the array have to be?

I'm not sure that you could use a string:

I would like to do the following:
Rob Spoor

Joined: Oct 27, 2005
Posts: 19679

Then change the array type:

How To Ask Questions How To Answer Questions
Thomas Feld

Joined: Sep 08, 2009
Posts: 3
Thanks a lot!
Thats axactly what I needed
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Change jLabel properties in loop