[Webinar] Streamline your web hosting managementRegister Today


Changing the component Color

Posted on 2000-01-13
Medium Priority
Last Modified: 2010-04-01
How do we change the component color depending upon the desktop setting?
Question by:jadhavv
  • 2

Expert Comment

ID: 2352184

Use setForeground and setBackground in Component.

Accepted Solution

herbie_b earned 200 total points
ID: 2354583
Use the java.awt.SystemColor class, which is a subclass of the Color class.
It has a lot of static fields of type SystemColor.
E.g. the menuText field holds the background color for menus.  
When the system color is changed, the RGB values of these  SystemColor objects are also dynamically changed.

For a description of all fields, look in the JDK docs, e.g. here:


Expert Comment

ID: 2392120
jadhavv, please either accept or reject my answer! (1)

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

590 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