This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "gmail like custom "select all" control" Watch "gmail like custom "select all" control" New topic
Author

gmail like custom "select all" control

Mansoor Akhtar
Greenhorn

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.

Thanks,
Mansoor

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
Greenhorn

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
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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: http://aspose.com/file-tools
 
subject: gmail like custom "select all" control
 
Similar Threads
My feedback about gmail
secure web based mail
E mail notifier
Gmail Feedback
need a companian