Making a picture gallery with scroll bar

Hi,

I am total newbie to java and the java GUI is making me getting a little bit crazy. I wanted to create a picture gallery where by I can place images dynamically from the file I've choosen and it should display in thumbnail size in display area. For putting any amount of pictures dynamically, I guess I will need to use JScrollPane to display pictures so that user can scroll down to see some of the picture which are not visable. But I can't figure out how can I add more than one component inside the JScrollPane. Can anyone help me with this?

[564 byte] By [pandoramica] at [2007-10-3 10:29:15]
# 1
Use a JPanel with the appropriate [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Layout Manager[/url], probably a GridLayout. Then add labels to the panel and the panel to the scroll pane.
camickra at 2007-7-15 5:51:52 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks. I got the idea. By the way, is there anyway to dynamicall generate array of components? As in may be JButton ButtonArray[]=new JButton();? I cannot do in this way. I am not so sure what's the correct syntax to instantiate array of item and creating it one by one. Any idea?
pandoramica at 2007-7-15 5:51:52 > top of Java-index,Desktop,Core GUI APIs...
# 3
hi!yes you can reinitiate the array again.....JButton[] buttonArray=new JButton[0];again in your code any where buttonArray=new JButton[/*your count*/2];:)
Aniruddha-Herea at 2007-7-15 5:51:52 > top of Java-index,Desktop,Core GUI APIs...
# 4

if (returnVal == JFileChooser.APPROVE_OPTION) {

File file[]= fcSelectFile.getSelectedFiles();

//This is where a real application would open the file.

int count=0;

while(count<file.length)

{JTextArea selectedFile[]=new JTextArea[count];

PnlUpload.add(selectedFile[count]);

selectedFile[count].setText("Opening: " + file[count].getName() + ".\n");

count++;

}

}

I tried something like this. But somehow it doesn't show anything when I select a few files? I am not too sure what is wrong. Btw, this is only partial code and you can assume other things like Panel and Filechooser are already working. What is not working is this JTextArea array.>

pandoramica at 2007-7-15 5:51:52 > top of Java-index,Desktop,Core GUI APIs...
# 5

hI!

if (returnVal == JFileChooser.APPROVE_OPTION) {

File files[]= fcSelectFile.getSelectedFiles();

//This is where a real application would open the file.

int count=0;

PnlUpload.removeAll();

JTextArea selectedFile[] = new JTextArea[files.length];

while(count < file.length)

{

selectedFile[count] = new JtextArea("Opening: " + file[count].getName() + ".\n");

PnlUpload.add(selectedFile[count]);

//selectedFile[count].setText("Opening: " + file[count].getName() + ".\n");

count++;

}

try this....

:)

Aniruddha-Herea at 2007-7-15 5:51:52 > top of Java-index,Desktop,Core GUI APIs...
# 6
Wow!! This is great. It works. Thanks a million. Btw.. what does this Duke Dollars do? Anyway, I add some duke dollars for you as gratitude.
pandoramica at 2007-7-15 5:51:52 > top of Java-index,Desktop,Core GUI APIs...