Solved

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

Posted on 2008-10-22
6
1,672 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
Comment Utility
You can set the property:
          "Button.foreground"

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

Expert Comment

by:sciuriware
Comment Utility
Sorry I meant:

          "Button.disabledForeground"

which defaults to:

             InactiveTextColor

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
Try this:

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

Author Comment

by:prain
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 60
return in catch statement 1 40
topping2 challenge 13 56
Problem to start Neon 20 49
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now