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,
At least one GTK theme draws a hash pattern

Windows Vista and XP draws a square:
.png)
The older Windows look draws a check with a hashed background:
.gif)
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.
Posted by Romain Guy | February 2, 2007 5:29 PM
Posted on February 2, 2007 17:29
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.
Posted by Danno Ferrin | February 2, 2007 10:52 PM
Posted on February 2, 2007 22:52