Results 1 to 6 of 6
Thread: Loading images from an Array
- 04-15-2011, 10:03 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 11
- Rep Power
- 0
Loading images from an Array
Hello, i have an array for example
I want to set an Image Icon using the images array.Java Code:images [0][0] = "images1.gif"; images [0][1] = "images2.gif";
That isnt the right syntax so wondered if anyone knew.Java Code:pictureimage[i].setIcon(new ImageIcon (images[0][1]));
Many Thanks
- 04-15-2011, 11:11 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Well, considering that you don't have images in that array, but rather strings that seemingly represent filenames (without paths), no, that's not the correct syntax.
What does the API docs for ImageIcon say? What possible constructors can you use?
- 04-15-2011, 11:12 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 11
- Rep Power
- 0
So in that array, would i need to include filenames for it to work? Im new to java so sorry if its a really stupid question.
- 04-15-2011, 11:26 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
filenames is what you already have. What are the possible constructors for ImageIcon? See the API docs.
A filename is acceptable, but hopefully the cwd is correct (probably not as it almost never is what a "newbie" expects it to be). You might also want to explain exactly what you mean by "isnt the right syntax". Do you get a compiler message? post it (completely). Do you get an exception? post it (completely). Does something else happen? describe it (fully). I believe you should be getting the idea by now.Last edited by masijade; 04-15-2011 at 11:29 AM.
- 04-15-2011, 11:35 AM #5
Member
- Join Date
- Jan 2011
- Posts
- 11
- Rep Power
- 0
Would it be this one?
ImageIcon(Image image)
Creates an ImageIcon from an image object.
- 04-15-2011, 11:37 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
Question about loading images in a WebStart application
By Psyclone in forum AWT / SwingReplies: 1Last Post: 03-26-2010, 10:41 PM -
Loading large images in JavaME
By b12 in forum Advanced JavaReplies: 1Last Post: 04-01-2009, 11:02 AM -
Loading images in seperate packages?
By Bibendum in forum New To JavaReplies: 0Last Post: 03-02-2008, 10:43 PM -
Loading Images - Imp
By Thulasiraman in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 09:33 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks