*
The moose likes Swing / AWT / SWT and the fly likes Button appearance in AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Button appearance in AWT" Watch "Button appearance in AWT" New topic
Author

Button appearance in AWT

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Feb 04, 2001
Posts: 5
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

Joined: Nov 08, 2000
Posts: 154
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Button appearance in AWT
 
Similar Threads
WA #1.....word association
Look of JTabbedPane
Mock exam
Urgent awt code
Bugtraking Devaka's Examlab