Solved

How to Color Elements in the JComboBox

Posted on 2001-07-05
4
372 Views
Last Modified: 2008-02-01
Dear Friends


How do i color different elements in the JComboBox.
I want that when i select an element in the JComboBox it is highlighted with different color but not with the deafult color. i want different colors for different elemts in the combobox.



Thanxs in advance

Bye
prasad
0
Comment
Question by:sdinfosys
[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
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 30 total points
ID: 6258332
prasad,

You need to define your own ListCellRender using the setRenderer method.
Your renderer probably just needs to extend DefaultListCellRenderer adding the enhancements you require.
0
 

Author Comment

by:sdinfosys
ID: 6258396
Objects

Thanxs Objects for your instant reply.
i will try that and get u know.

bye objects
Prasad
0
 
LVL 92

Expert Comment

by:objects
ID: 6258399
No worries, let me know if you have any problems :)
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8975012


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


-- points to objects


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
map related example 6 59
eclipse buid path vs tomcat lib path 10 38
String array comparison 4 46
Pass multiple values or string arrays in java as a parameter 3 43
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

749 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