• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Array to JLabel Array

 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to take a String Array that was passed from another Class and insert the text into a JLabel Array to display on a JFrame. The length of the String Array will be different each time. I have used the following code in my attempts:
1)
JLabel[] labels;//gives me a variable may not have been intialized
2)
int y = Array.getLength(info)// where info is the name of the StringArray, JLabel[y] label; //it give me a cannot recognize complier error
3)
JLabel[] labels = {};
and
JLabel[] labels = {new JLabel(info[0])};
When I use the code above and use a loop to try to add the rest of the variables from the STring array to this array I get an ArrayOutOFIndexException.
Any help would be appreciated at all
Thank you,
Jesse
 
Ajay Singh
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try these corrections (i assume that info is the string array)
1.

2.


3.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic