File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


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 » Beginning Java
Bookmark "String Array to JLabel Array" Watch "String Array to JLabel Array" New topic
Author

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:
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

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

2.


3.
 
jQuery in Action, 2nd edition
 
subject: String Array to JLabel Array