Results 1 to 6 of 6
- 06-06-2008, 05:04 AM #1
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
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
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 .Java Code:for (int i = 1; i <= TOTAL_NUMBER_OF_IMAGES; i++) { imageIcon[i] = new ImageIcon("/image/flag" + i + ".gif"); }
thanks...
- 06-06-2008, 05:58 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You mean want to display images in sorted order by name? And what happened when you try it in your way?
- 06-06-2008, 06:09 AM #3
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
- 06-06-2008, 06:25 AM #4
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
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..
- 06-06-2008, 06:38 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
In simple way, before do this,
validate that image is available in image file.Java Code:ImageIcon("/image/flag" + i + ".gif")
- 06-06-2008, 09:31 AM #6
Member
- Join Date
- Jun 2008
- Posts
- 6
- Rep Power
- 0
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
-
how to import a picture into an applet
By cecily in forum Java AppletsReplies: 2Last Post: 01-15-2010, 08:51 PM -
Picture help
By deathnote11 in forum AWT / SwingReplies: 13Last Post: 06-03-2008, 05:46 PM -
Reading a directory and getting the filename
By mrjunsy in forum Advanced JavaReplies: 1Last Post: 05-10-2008, 02:36 AM -
Picture in a JFrame problem
By saytri in forum New To JavaReplies: 3Last Post: 01-12-2008, 09:44 AM -
Print a picture file
By oli001 in forum New To JavaReplies: 0Last Post: 11-26-2007, 01:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks