« SWT vs. Swing comes full circle | Main | Groovy vs. Cocoa: invoking a method on the main GUI thread »

Can We Get a Three State CheckBox in Java 7?

A lot of the blogging about swing has been about making things shiny, or spiffy, or even flashy. But how about adding some basic functionality that just about every look and feel except swing has: Three State CheckBoxes.

What kind of crazy talk is that? Check boxes are simple on-off switches, which can answer yes and no questions, like "I would like fries with that" and "Please send me spam." Yes, that is certainly the use case that check boxes were designed for, and by default should be how you could view them. But there are times where a simple yes or no could have yes and no, or and indeterminate answer. Major toolkits vary on how this is rendered,

Apple draws a dash:

At least one GTK theme draws a hash pattern

Windows Vista and XP draws a square:

The older Windows look draws a check with a hashed background:

Heck, even Version 3 of Cascading StyleSheets specifies and indeterminate checkbox! And they test for it too. (IE7 passes, Firefox fails, I'm just saying.)

There even exist written guidelines on how not to abuse them.

But wait, it gets crazier, if you dig into the XPStyle class of your src.zip (particularly in 5.0u8 or later) you will see that constants even exist for accessing the indeterminate checkbox. And it works, because I've done it.

So, is there anything that a lowly developer like me can do to get this into Java 7? I mean other than hack at the swing code when it is released and show how it is done. Doesn't it need some JSR to be worked under?

Comments (2)

As a user I've always, always hated three-state checkboxes. I find them awkward to use at best. Anyway, the Swing team offers such a checkbox, if I remember correctly, through the SwingLabs project. Check out the SwingX sub-project at http://swingx.dev.java.net.

Danno Ferrin:

Are you sure swingx has it? I haven't looked deeply into it since I left Intelliden about a year ago but I don't ever remember a three state or indeterminate checkbox coming through. I have however used the combo box auto complete and the task pane when I was at my previous job.

It's certianly not in the javadoc or a published jar, unless it's named something bizarre.

Post a comment


About

This page contains a single entry from the blog posted on February 2, 2007 12:29 PM.

The previous post in this blog was SWT vs. Swing comes full circle.

The next post in this blog is Groovy vs. Cocoa: invoking a method on the main GUI thread.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33