JCheckBox is the Java Swing implementation of a check box, an item that can be selected or deselected, and which displays its state to the user.
Questions tagged [jcheckbox]
613 questions
9
votes
4 answers
Align a JLabel with the text of a JCheckBox
Is there a look-and-feel-independent way to align a component (e.g. a JLabel) horizontally with the text of a JCheckBox?
I am trying to use values from the UIDefaults to predict the location of the text relative to the top-left corner of the…

finnw
- 47,861
- 24
- 143
- 221
8
votes
5 answers
How to make JTable column contain checkboxes?
Preface: I am horrible with java, and worse with java ui components.
I have found several different tutorials on how to add buttons to tables, however I am struggling with adding checkboxes. I need to have a column that draws a text box ticked on…

theraven
- 4,825
- 3
- 20
- 20
8
votes
4 answers
Listeneing for changes in JCheckBox in a JTable
How do I listen for changes in a JTable column that has a JCheckBox in it? I want to know when the user selects/deselects the check box. The class for the column is set as boolean so it is automatically rendered as a JCheckBox.

user3245747
- 805
- 2
- 17
- 30
8
votes
1 answer
Using icons with JCheckBox
I have a swing application in which I want to use a JCheckbox with an icon. I constructed the icon as follows:
JCheckBox unsubmit = new JCheckBox("Unsubmit",applet.undo);
When I do this, the label and the icon appear in my GUI but the box…

Elliott
- 5,523
- 10
- 48
- 87
7
votes
4 answers
how to add a mouse listener to a JTable's cell holding a Boolean value rendered as checkbox
I have a JTable with a custom model implemented extending AbstractTableModel.
public abstract class AbstractTable extends AbstractTableModel{
public Class extends Object> getColumnClass(int c) {}
}
Because I've implemented the…

Heisenbug
- 38,762
- 28
- 132
- 190
7
votes
3 answers
JCheckbox changes state twice when I show a dialog on statechange, how to fix?
I have a checkbox that, when the user selects it, should spawn a dialog with further info, and upon reaction from the user, do something. My code looks basically like this:
private void onItemStateChanged(java.awt.event.ItemEvent evt) {
…

random_error
- 365
- 4
- 16
7
votes
4 answers
Multiple row selection in JTable
I have a JTable, that has one column that is text which is not editable and the second column is a check box that displays boolean values.... Now what i want is, when the user selects multiple rows and unchecks any one of the selected check boxes,…

sasidhar
- 7,523
- 15
- 49
- 75
7
votes
5 answers
uncheck checkboxes in java
In my program, I want to uncheck all the checkboxes whenever this method is called. Can someone explain why it isn't working? Whenever I call this method the checkboxes are still selected.
private void…

user2175095
- 71
- 1
- 1
- 5
6
votes
1 answer
adding border to jcheckbox
Does anyone know if there is an easy way to put a border around a JCheckBox object including the label? setBorder doesn't seem to have any effect. I know I could put each checkbox inside of a JPanel and border that, but is there no way to border the…

f1wade
- 2,877
- 6
- 27
- 43
6
votes
3 answers
How to identify a direct click on a JCheckBox in a JTable?
With a JCheckBox as an Editor in a JTable column, I would like to ignore mouseclicks in the space left and right of a CheckBox in a TableCell.
I have found a discussion from 2011 on the Oracle forum, but the problem was not solved there:…

bobndrew
- 395
- 10
- 32
6
votes
2 answers
Dynamically create jCheckBox and add to a jScrollPane
EDIT: Using the solutions presented below, I have changed the code to have a JPanel inside a JScrollPane. Using a JButton i add JCheckBoxes to the JPanel inside the JScrollPane. This was one problem solved, as the a JScrollPanecan only take one…

wmdvanzyl
- 352
- 2
- 5
- 17
5
votes
2 answers
Why does setSelected on JCheckBox lose effect?
Can someone explain to me why I lost the selection (set by setSelected()) for JCheckBox when I put the JOptionPane into the ItemListener?
Is this a bug ?
It is curious, that if this process is delayed with invokeLater(), setSelected() works…

mKorbel
- 109,525
- 20
- 134
- 319
5
votes
2 answers
Make JCheckbox bigger..?
i want to make my JCheckboxes in a JTable bigger (for Touchscreen), but it doesn't change the size.
I tried it with
setPrefferedSize
setSize
What should I do?..

Christian 'fuzi' Orgler
- 1,682
- 8
- 27
- 51
5
votes
3 answers
Can i use JCheckbox to show "mixed state"
In windows it is possible to show a grayed out JCheckbox, to show that the collection of data which it represents not all items have the same value.
Is this even possible with a JCheckBox?
How do i go about this?
(Hoping there's a way to not…

Houtman
- 2,819
- 2
- 24
- 34
5
votes
3 answers
JPanel Action Listener
I have a JPanel with a bunch of different check boxes and text fields, I have a button that's disabled, and needs to be enabled when specific configurations are setup.
What I need is a listener on the the whole JPanel looking for events, whenever…

Ronin
- 93
- 1
- 2
- 11