Solved

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

Posted on 2008-10-22
6
1,894 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
jsp insert to database example 2 89
maven disable workspace resolution 1 75
java example issue 5 65
Java class and jar 3 59
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

734 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