• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

image button in awt

 
ravi vardhin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i put an image in button on an applet using AWT??
please reply
ravi
 
Shaunak Desai
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yes Ravi..
You can easily put an image on your awt button.
Use ImageIcon class...and the getDocumentBase() method....
In this method, you give the path of file in which your image is saved .
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ImageIcon class is part of Swing... not part of the AWT... and the AWT Button does not even support ImageIcon... only JButton does...

Ravi, I have previously posted some code that will help you out in this thread...

http://www.javaranch.com/ubb/Forum2/HTML/000865.html

-Nate
[This message has been edited by Nathan Pruett (edited June 14, 2001).]
 
Jonathan W. Brett
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just add the image u want, then put an actionPerformed listener on it. If you want, you can get fancy and put mouse Listeners on it too
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic