Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes JButton background color Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton background color" Watch "JButton background color" New topic
Author

JButton background color

Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Hello there,
How can i clear the background color of a JButton which current background is blue?
What is the RGB color code for the default button color?
Thanks
Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
Howdy Pardner. You could use getBackground to store the colour of the button before you change it to blue, then use setBackground(storedColor). I thought that there might have been a constant defined somewhere in the swing package for the default colour but I could not find one.
Mindy Wu
Ranch Hand

Joined: Jan 12, 2001
Posts: 121
Thank you for your help!
Also, i found the default background color is R=204, G=204, B=204.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Actually, the background color could change based on the Look and Feel. You can use UIManager.getColor( "Button.background" ) to get the default background color of buttons in the current Look and Feel.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButton background color
 
Similar Threads
JButton is not displaying the background color
CSS and JSP
ListBox
java swing
Flashing a row in Jtable