Results 1 to 2 of 2
Thread: JLabel Array?
- 06-10-2008, 10:27 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 8
- Rep Power
- 0
JLabel Array?
I just started learning Java! I am trying to create an array of JLabels. Is this possible? I cannot seem to get the code right. I plan to have them all display the same icon.
I tried this code to declare the array, but it is most certainly incorrect:
Help?Java Code:static JLabel[] labelname = new JLabel [20] (imageIconHere);
- 06-11-2008, 03:13 AM #2
Java Code:ImageIcon icon = new ImageIcon(imagePath); // allocate array for 20 labels JLabel[] labels = new JLabel[20]; // all elements of this array are null, not instantiated // initialize the array by instantiating the elements for(int i = 0; i < labels.length; i++) { labels[i] = new JLabel(icon); } // labels are ready to go...
Similar Threads
-
GUI - JLabel
By Azndaddy in forum New To JavaReplies: 8Last Post: 05-02-2008, 07:03 AM -
help me with JFrame and JLabel
By michcio in forum New To JavaReplies: 5Last Post: 11-20-2007, 07:44 AM -
How to use JLabel with html
By leonard in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 04:43 PM -
JLabel
By Jack in forum AWT / SwingReplies: 2Last Post: 07-02-2007, 01:55 PM -
JLabel
By Freddie in forum AWT / SwingReplies: 2Last Post: 05-29-2007, 02:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks