Results 1 to 4 of 4
  1. #1
    dofod is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Exclamation Displaying An Array Of Images

    So Here's My Code:
    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();
    	}
    	
    }
    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...
    Can Anyone check the problem with the code?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

    Default 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, and
    Everything works fine ...
    The 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.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    dofod is offline Member
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Default 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...

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

    Default Re: Displaying An Array Of Images

    Quite apart from your 4-5 files, JFrame does not have a revalidate() method.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. displaying images
    By sukanya in forum JavaServer Pages (JSP) and JSTL
    Replies: 6
    Last Post: 03-25-2012, 02:46 PM
  2. Displaying multiple images
    By asmitarnd in forum AWT / Swing
    Replies: 2
    Last Post: 04-19-2011, 12:14 PM
  3. Displaying moving images
    By Maulik in forum AWT / Swing
    Replies: 3
    Last Post: 04-02-2011, 12:00 AM
  4. [SOLVED] Need help in displaying images
    By kirly in forum Advanced Java
    Replies: 3
    Last Post: 10-21-2008, 05:36 AM
  5. Images not displaying in JSP in IE7
    By chadscc in forum Advanced Java
    Replies: 0
    Last Post: 11-13-2007, 03:24 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •