Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP!!!! how do i get image by extending Canvas object

 
Richard Teston
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
help...
i have this code i've extended the canvas object, basically i'm coding my own button by using canvas but how do i get image from a file
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
How about:
Image im = Toolkit.getDefaultToolkit().getImage( "C:\\TEMP\file.gif" );
Regards,
Manfred.
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also, since you are using canvas i guess you are using AWT and not swing.
if u ecide to switch to swing then u can use the class called ImageIcon. only needs a filename in its constructor.
ImageIcon x=new ImageIcon("file name");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic