Solved

How to change the disabled background color (Normally Gray) of a button?

Posted on 2008-10-22
6
1,799 Views
Last Modified: 2013-12-29
Hello,

Small things always...

How do I change the disabled background color of a JButton to something else other than std. Gray. Is this possible?.

prain
0
Comment
Question by:prain
  • 4
6 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 22777749
You can set the property:
          "Button.foreground"

Warning: it behaves different in various look&feel's.
;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 22777766
Sorry I meant:

          "Button.disabledForeground"

which defaults to:

             InactiveTextColor

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 22777908
Try this:

               UIManager.put(Button.disabledForeground", Color.RED);
0
 

Author Comment

by:prain
ID: 22778083
So how do I do this. Can you show an example?. Do I have to fire a property change call?.

JButtoon aButton = new JButton();
...
..
if (what ever the condition)
{
  //I want to disable the button and change the disabled color to something else other than Gray
  aButton.set??????();            // ??
}
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 125 total points
ID: 22779144
Reading is hard these days:

               UIManager.put(Button.disabledForeground", Color.RED);

as the first line of your code and all disabled buttons should have that colour.

;JOOP!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
varialbe initialization 11 37
Glassfish admin console not working 1 32
Is there a simpler dropbox system? 10 34
Is Applet the way to go for my drag and drop system? 8 25
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question