This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Button appearance in AWT

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic