I found a way to make a tri-state checkbox by simply adding a listener:
public class TriStateActionListener implements ActionListener{
final protected Icon icon;
public TriStateActionListener(Icon icon){
this.icon=icon;
}
public static Boolean getState(javax.swing.JCheckBox cb){
if (cb.getIcon()==null) return null;
if (cb.isSelected()) return true;
else return false;
}
public void actionPerformed(ActionEvent e) {
javax.swing.JCheckBox cb=(javax.swing.JCheckBox)e.getSource();
if (!cb.isSelected()){
cb.setIcon(icon);
}
else if (cb.getIcon()!=null){
cb.setIcon(null);
cb.setSelected(false);
}
}
}
Then in the application code, it's just a single line:
jCheckBox1.addActionListener(new TriStateActionListener(getResourceMap().getIcon("TriStateIcon")));
After all the feedback, I'm thinking a drop-down may be a better choice. But, I wanted to share my code here for everyone else.