Solved

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

Posted on 2008-10-22
6
1,939 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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