Results 1 to 6 of 6
  1. #1
    norazanita is offline Member
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Unhappy how to display the picture when the filename is not in order

    hi..anyone help me on this,

    in my picture file, i have a list of image and some of the filename is missing ( or been deleted already)
    0001.gif
    0002.gif
    0010.gif
    1001.gif
    9800.gif
    9999.gif

    now i would like to display .I use the JLabel as the container to display my picture and the picture set as ImageIcon.

    i can veiw when i press the "next" and " previous" button if the picture file in sequence which is
    0001.gif
    0002.gif
    0003.gif
    0004.gif
    0005.gif
    0006.gif

    as i can access using this code

    Java Code:
       for (int i = 1; i <= TOTAL_NUMBER_OF_IMAGES; i++) {		 imageIcon[i] = new ImageIcon("/image/flag" + i + ".gif");				   	    }
    can someone give me some idea / example / way on how to show when i click the "next" and "previous" it still show the image when the filename is not in order as above .

    thanks...

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    You mean want to display images in sorted order by name? And what happened when you try it in your way?

  3. #3
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    he's saying that some files dont exist. I would do a simple check if the file is null or something like that.
    My IP address is 127.0.0.1

  4. #4
    norazanita is offline Member
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Default

    now with the filename that contain in the folder where some is missing or been deleted and i want to display when an action been perform (eg. "NEXT" or "PREVIOUS" button )..

    if i use the for loop, when i click next or previous...it wont display the image.

    need help on that..

    thanks...hope Eranga and Zosden able to help me...or any one else..

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    In simple way, before do this,

    Java Code:
    ImageIcon("/image/flag" + i + ".gif")
    validate that image is available in image file.

  6. #6
    norazanita is offline Member
    Join Date
    Jun 2008
    Posts
    6
    Rep Power
    0

    Default

    Dear Eranga,

    i did as what u suggested..but it is not working.. i think i better i send u my code maybe u have better idea...

    <code>

    BufferedImage imageIcon1 = null;
    try {
    imageIcon1 = ImageIO.read(new File("image/flag6.gif"));
    } catch (IOException e) {

    }


    JLabel xxx = new JLabel ( new ImageIcon (imageIcon1));
    xxx.setBounds(200,50,260,250);
    xxx.setEnabled(true);
    topPanel.add (xxx);



    label1 = new JLabel( "PIC1:" );
    label1.setBounds( 100, 150, 50, 20 );
    label1.setLabelFor( jlblImageViewer1 );
    topPanel.add( label1 );


    </code>

    hope u can help me..

    thanks..

Similar Threads

  1. how to import a picture into an applet
    By cecily in forum Java Applets
    Replies: 2
    Last Post: 01-15-2010, 08:51 PM
  2. Picture help
    By deathnote11 in forum AWT / Swing
    Replies: 13
    Last Post: 06-03-2008, 05:46 PM
  3. Reading a directory and getting the filename
    By mrjunsy in forum Advanced Java
    Replies: 1
    Last Post: 05-10-2008, 02:36 AM
  4. Picture in a JFrame problem
    By saytri in forum New To Java
    Replies: 3
    Last Post: 01-12-2008, 09:44 AM
  5. Print a picture file
    By oli001 in forum New To Java
    Replies: 0
    Last Post: 11-26-2007, 01:40 PM

Posting Permissions

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