View Single Post
  #1 (permalink)  
Old 06-03-2008, 02:04 AM
willemjav willemjav is offline
Senior Member
 
Join Date: Dec 2007
Location: Spain
Posts: 342
willemjav is on a distinguished road
JList and records, what to do to solve the problem
IŽd like to list a series of image file names, and to be able to select them, one by one. The class JList seems suitable for that idea. Pasting a list (in the form of a array) turns out to be no problem, for example:
String[] test = { "pic1", "pic2", "picetc"};
Piclist = new JList(test);
Piclist.setSelectionMode(ListSelectionModel.SINGLE _INTERVAL_SELECTION);
Piclist.setLayoutOrientation(JList.VERTICAL);
Piclist.setVisibleRowCount(-1);
JScrollPane PiclistScroller = new JScrollPane(Piclist);
PiclistScroller.setPreferredSize(new Dimension(200, 500));
textPanel.add(PiclistScroller);

And the image names show up just fine.

But what happens when I do the following:
private Img[] img;

private static class Img { // the image file info record array
String name, textinfo, infotextcolor, infotextsize;
int duration, numberpic, fade, infotextx, infotexty;
}

img = new Img[numberpic]; // according the number of pic
for ( i = 0; i < numberpic; i++)
img[i] = new Img();

When I try to pass the "name" field into the object:
Piclist = new JList(img.name);
I get “can not find symbol variable name”
WHY?
"Img[what ever number in the range].name" holds a picture file name.
So Img.name should point to that array in general, or not?

What should I do to solve this problem
Saludos willemjav
Reply With Quote
Sponsored Links