• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding an image

 
charlie mills
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i add an image that is in a different file directory to my java source files and my class files?

so far i have:
[code]
ImageIcon image = new ImageIcon("untitled.bmp");
picture = new JLabel(image) ....etc....
 
Campbell Ritchie
Marshal
Posts: 52516
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried passing the full path as an argument to the ImageIcon constructor?
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or at least the path relative to the current folder (i.e. the folder from where you started the Java application).
 
charlie mills
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i don't know how to do that.
do you mean:
ImageIcon image = new ImageIcon("/images/untitled.bmp");
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> do you mean:

try it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!