• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

gmail like custom "select all" control

 
Mansoor Akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am wondering how can we develop the custom JComboBox like Gmail "Select All" component having a JCheckBox at the top, which does not come in the drop down menu, but is click-able.

Any idea(s) and/or working examples would be highly appreciated.

Thanks,
Mansoor

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a listener to the 'checkbox at the top', when clicked,
iterate all the checkboxes in the dropdown, setting their state accordingly
 
Mansoor Akhtar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to put only one 'CheckBox at the top' INSIDE the JComboBox ???
and the rest of the components shown in the drop down menu are not really chechboxes ..... they seem to be simple strings ...
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not going to be easy. For starters, the GMail check box you're talking about is a tristate component whereas JCheckBox has only two selection states, so you'd have to fist develop tristate functionality

If I were to target doing this, I would start with a JToggleButton or maybe a JButton, add tristate functionality (probably by extending DefaultButtonModel) and apply a custom icon wrapped around UIManager.getIcon(CheckBox.icon). The paintIcon implementation would query the button state and paint accordingly. A popup menu would house the selection conditions, and ActionListeners on the menu items would take care of the filtering to apply the selection status of the items in the list.

I wouldn't consider using JComboBox at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic