Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2005

Tip: Looking for answers? Try searching our database.

setting background color in a disabled JComboBox

Thread view: 
filiberto.silvestri@welcometechnology.it - 31 Mar 2005 15:33 GMT
Hi,

I need to set the background color of a JComboBox when the combo is
disabled. JComboBox.setBackground() works when the combo is enabled,
but it doesn't when the combo gets disabled.

I tried defining a renderer, but the renderer mainly controls the
rendering of the items in the combo's popup list. And again, whether
using a renderer or not, this has no effect on the combo's background
color.

It also thought about keeping the combo always enabled, just making it
"appear" disabled to the user when the combo gets "disabled".

This would require esentially the follwing:

    (1) disabling focusabiliy of the combo
    (2) avoiding the combo's popup list to show up

The problem here is point (2).

A MouseListener does not work here because it intercepts mouse clicks
after they occurred.

I tried adding a PopupMenuListener to the combo in order to get
informed when the popup list will be displayed. The problem is that a
PopupMenuEvent used in PopupMenuListener's popupMenuWillBecomeVisible()
has no cancel method like input events. So I know when the popup list
gets displayed but I don't know how to prevent this showing up. I tried
to use JComboBox.hidePopup() in the event handler, but this only keeps
the popup list displayed, once it gets shown.

Thanks for reading this.

I would be great if somebody could help me.
Christian Kaufhold - 31 Mar 2005 16:46 GMT
> I need to set the background color of a JComboBox when the combo is
> disabled. JComboBox.setBackground() works when the combo is enabled,
[quoted text clipped - 4 lines]
> using a renderer or not, this has no effect on the combo's background
> color.

http://groups-beta.google.com/group/comp.lang.java.gui/msg/6cf1fb7bde6adae2
http://groups-beta.google.com/group/comp.lang.java.gui/msg/76a6ab755da9093d?dmod
e=source

(for an unknown reason, my posting is missing from that thread).

Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.