?
Solved

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

Posted on 2008-10-22
6
Medium Priority
?
2,005 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 500 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

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…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 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