File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes String Array to JLabel Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Array to JLabel Array" Watch "String Array to JLabel Array" New topic

String Array to JLabel Array

Jesse Walker
Ranch Hand

Joined: Aug 18, 2004
Posts: 50
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:
JLabel[] labels;//gives me a variable may not have been intialized
int y = Array.getLength(info)// where info is the name of the StringArray, JLabel[y] label; //it give me a cannot recognize complier error
JLabel[] labels = {};
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,
Ajay Singh
Ranch Hand

Joined: Dec 13, 2006
Posts: 182
try these corrections (i assume that info is the string array)


I agree. Here's the link:
subject: String Array to JLabel Array