File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes gmail like custom Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "gmail like custom "select all" control" Watch "gmail like custom "select all" control" New topic

gmail like custom "select all" control

Mansoor Akhtar

Joined: Jul 11, 2010
Posts: 12
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.


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
add a listener to the 'checkbox at the top', when clicked,
iterate all the checkboxes in the dropdown, setting their state accordingly
Mansoor Akhtar

Joined: Jul 11, 2010
Posts: 12
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

Joined: May 03, 2008
Posts: 5115

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.

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: gmail like custom "select all" control
It's not a secret anymore!