Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tristate Checkboxes in Java

I could really use a tri-stated checkbox in Java. It sounds like a simple thing, but I've only seen really ugly implementations [note: link now broken].

Three radio buttons just take up too much real estate and will probably be confusing for the users in my case. It's basically for a search dialog. I need true, false or "don't care" options. Is there a different technique that people use?

like image 634
User1 Avatar asked Aug 11 '09 22:08

User1


People also ask

What is a tri state checkbox?

A tri-state checkbox can be checked, not checked, or partially checked. The condition of being partially checked is based on the selection of child elements. If all child elements are selected, the parent checkbox is checked.

What is JCheckBox in Java?

public class JCheckBox extends JToggleButton implements Accessible. An implementation of a check box -- an item that can be selected or deselected, and which displays its state to the user. By convention, any number of check boxes in a group can be selected.

How do I know if JCheckBox is selected?

JCheckBox often uses the methods isSelected and setSelected. To select, or un-select, a box, use the setSelected(boolean) method. To check if a box is selected, use the isSelected() method.

Which method of JCheckBox returns the state of the check box?

The method to set the state is JCheckBox. setSelected(boolean) and the method for getting the state is JCheckBox. isSelected() which return a boolean value.


1 Answers

Use a drop-down.

like image 75
Gandalf Avatar answered Sep 24 '22 15:09

Gandalf