Results 1 to 4 of 4
Thread: Displaying An Array Of Images
- 04-01-2012, 07:22 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Displaying An Array Of Images
So Here's My Code:
Everything works fine when set to work out of for loop ie. for 3 or 4 images...but once put inside the for loop...images get downloaded....but somehow the frame does not display those images...it seems as if the frame is not being refreshed...Java Code:import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.*; public class GUI { public void ShowDialog(String Message) { JFrame frame = new JFrame("Message"); JOptionPane.showMessageDialog(frame,Message); } public void ShowResult(resultlist list[],JFrame f) throws MalformedURLException { JLabel lab[]=new JLabel[list.length]; for(int i=0;i<list.length;i++) {lab[i]=new JLabel();} File file[]=new File[list.length]; URL url[]=new URL[list.length]; Downloader X[]=new Downloader[list.length]; for(int i=0;i<list.length;i++) { file[i]=new File("\temp\\"+list[i].VideoName.toString()+".jpg"); System.out.println(list[i].ThumbnailUrl.toString()); System.out.println(list[i+1].ThumbnailUrl.toString()); url[i]=new URL(list[i].ThumbnailUrl.toString()); X[i]=new Downloader(url[i],file[i]); X[i].run(); } ImageIcon icon[]=new ImageIcon[list.length]; for(int i=0;i<list.length;i++) {icon[i]=new ImageIcon("\temp\\"+list[i].VideoName.toString()+".jpg");} for(int i=0;i<list.length;i++) {lab[i].setIcon(icon[i]);} Button b[]=new Button[list.length]; for(int i=0;i<list.length;i++) { f.add(lab[i]); b[i] = new Button("Download"); f.add(b[i]); b[i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); } f.setVisible(true); f.setSize(500,500); f.revalidate(); } }
Can Anyone check the problem with the code?
- 04-01-2012, 08:09 PM #2
Re: Displaying An Array Of Images
I gave you a link to a tutorial in your earlier thread. It doesn't look like you went through the section on layouts.
Oh, andThe code you posted doesn't even compile. Apart from using two classes you haven't provided, one of which has a name that violates the coding conventions, there's a call to a nonexistent method of a standard JDK class.Everything works fine ...
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-02-2012, 03:44 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: Displaying An Array Of Images
Thanks....Layout Manager Just Might Help Here...I'll Try It Out...The Code May Not Compile Coz Its Not The Full Code...It Is Divided Into 4-5 Files...I Just Posted The GUI Part...
- 04-02-2012, 05:22 PM #4
Similar Threads
-
displaying images
By sukanya in forum JavaServer Pages (JSP) and JSTLReplies: 6Last Post: 03-25-2012, 02:46 PM -
Displaying multiple images
By asmitarnd in forum AWT / SwingReplies: 2Last Post: 04-19-2011, 12:14 PM -
Displaying moving images
By Maulik in forum AWT / SwingReplies: 3Last Post: 04-02-2011, 12:00 AM -
[SOLVED] Need help in displaying images
By kirly in forum Advanced JavaReplies: 3Last Post: 10-21-2008, 05:36 AM -
Images not displaying in JSP in IE7
By chadscc in forum Advanced JavaReplies: 0Last Post: 11-13-2007, 03:24 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks