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 / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

JCheckBox inside JComboBox?

Thread view: 
Wizumwalt@gmail.com - 11 Aug 2005 19:38 GMT
Can JCheckBox's be put inside a JComboBox?

I'm trying the following, but it's not working ...

---
        myFilter = new JComboBox();
        myFilter.setMaximumSize(myFilter.getPreferredSize());

        b1 = new JCheckBoxMenuItem("test");
        b2 = new JCheckBoxMenuItem("test2");

        myFilter.addItem(b1);
        myFilter.addItem(b2);
       
        toolBar.add(myFilter);

---

Any help much appreciated.
Thomas Hawtin - 11 Aug 2005 20:23 GMT
> Can JCheckBox's be put inside a JComboBox?
>
[quoted text clipped - 11 lines]
>        
>         toolBar.add(myFilter);

The drop down list of a combobox isn't general purpose popup menu.
Anything to put a check box on it would be a hack.

I can't remember the exact details, but the JComboBox's menu is
implemented by the PL&F as a JList. Your obvious choices are to set a
list cell renderer that paints a check box as required or to replace or
supplement the list with your own component(s). Alternatively don't use
a JCheckBox at all.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



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.