File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Button appearance in AWT

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Can someone suggest me how to change the appearance of a button ? I want to display a button which will have an appearance of a pressed button after it is clicked for the first time.
 
sailesh gadia
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you can use 2 separate gifs.
1 for normal state and other for pressed state(i.e. when button is pressed)
See the code for Swing :
BTNGo.setIcon(new javax.swing.ImageIcon(getClass().getResource("normal.gif")));
BTNGo.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("pressed.gif")));
 
Grant Crofton
Ranch Hand
Posts: 154
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, you'd need to use Swing - the appearance of buttons in AWT is set by the OS.
If you need to use AWT, there might be some way of stopping the button recieving events once it's depressed, so it never changes it's appearance.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic