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?
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?
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.>
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....
:)