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
3
votes
2 answers
About Jcheckbox state, java
I am trying to do an action on button being clicked, but i need to make a check whether JCheckBox is checked or not.
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import…

Akado2009
- 381
- 1
- 4
- 11
3
votes
1 answer
JTable with JSpinner Enable/Disable
I've got a 3 column JTable. Column 2 is a checkbox which I want to enable/disable the JSpinner for that row.
I've got working how I want except for one thing -- The JSpinner doesn't actually look like its disabled (text and spinner buttons greyed…

mainstringargs
- 13,563
- 35
- 109
- 174
3
votes
3 answers
Get selected `JCheckBox` associated `id` on swing
Before I asked this question, I went through many examples, some of them are related, but did not answer my needs:
How to get the selected index of JCheckbox?
Java- Reading whether a checkbox is checked or not
I have a list as keyMessageList which…

Yubaraj
- 3,800
- 7
- 39
- 57
3
votes
3 answers
Creating multiple JCheckBox with multiple ActionListener
I made this sample below to simulate multiple JCheckBox creation and its Action Listener.
int global=0;
//some code
JCheckBox[] checkBox = new JCheckBox[2];
for(int i = 0; i <=1; i++){
checkBox[i] = new JCheckBox(strings[i]);
…

Victor Oliveira
- 3,293
- 7
- 47
- 77
3
votes
1 answer
Faulty repaint() of swing components when using custom background colors
When I use JCheckboxes or JScrollPane (applied to the main component that holds all others in order to generate a scrollable window) together with components that use
component.setBackground(new Color(R, G, B, A));
to define their background…

ChrisK
- 158
- 1
- 13
3
votes
3 answers
Make a textfield visible on itemStatechanged event of a checkbox
How to make a text field visible on itemStatechanged event of a check box in Swing?
I am trying to create a frame with a check box and a text field. I want the text field to be displayed only when the check box is selected. So when I initialize the…

java_learner
- 182
- 3
- 13
3
votes
3 answers
How do I add an empty row to JTable?
is there any way to an add empty row to jtable, where the first column is boolean, so it won't display the auto-generated checkbox?
I need it to separate groups of rows.
I tried using the code below, but it is NOT working:
model.addRow(new…

Michal
- 53
- 1
- 6
3
votes
3 answers
JCheckBoxMenuItem Default Value
I'm trying to add an options menu to my program, with the options changeable using JCheckBoxMenuItems. Whatever the value of these options is will be saved to a file when the program closes. The file will be read when the program starts and the…

Aaron
- 992
- 3
- 15
- 33
3
votes
2 answers
Setting button model makes check box non-operational
Why can't I set button model for JCheckBox?
The following code works and draws a window with one single check box in the center. Check box is operational:
public class JCheckButton_Test {
public static void main(String[] args) {
…

Suzan Cioc
- 29,281
- 63
- 213
- 385
3
votes
0 answers
Checkboxes and Radio Buttons Together in a JTree
I'd like to create a JTree that more or less has the following structure (with a hidden root node)
[No Option] Main Dish
[Radio Button] Steak
[Radio Button] Fish
[Radio Button] Filet Mignon
[Checkbox] Side Dish
[Checkbox] Mashed…

Thunderforge
- 19,637
- 18
- 83
- 130
3
votes
2 answers
JButton, JCheckBox and similar interactors do not change visually
Here is a simple graphics programs which adds some stars on the screen.
import acm.graphics.*;
import acm.program.*;
import java.awt.event.*;
import javax.swing.*;
/**
* This program creates a five-pointed star every time the
* user clicks the…

mgus
- 808
- 4
- 17
- 39
3
votes
1 answer
Text Missing On Checkbox Component for Swing After Adding Action
I'm writing a simple Swing app. I tried adding a checkbox as listed below. Once I added the actionHandler loadPickers the name Foo disappeared from where it was sitting next to the right of chckbxNewCheckBox. I tried adding a call to…

Jazzepi
- 5,259
- 11
- 55
- 81
3
votes
2 answers
Trouble with JCheckBox checked toggle logic in a JList in Java
Hi I am having trouble with toggling a check box that is in a JList, I wish for when an item is clicked to have the check box tick, and if it is ticked again i want it to toggle to unticked. I want to have it possible to have multiple items to be…

Matthew Pigram
- 1,400
- 3
- 25
- 65
3
votes
4 answers
How to count number of JCheckboxes checked?
I have 11 different checkboxes in my JFrame and want to be able to get a number whenever one is checked for how many total are checked. I know how to set up an ItemListener and see if one is checked, but I am not sure how I could check all of…

Wilson
- 8,570
- 20
- 66
- 101
2
votes
1 answer
Get the row of the TableCellRenderer on itemStateChanged
I have a custom TableCellRenderer (ValueRenderer) for a JTable, the cell is a Checkbox.
I have attached an ItemListener to the valueRenderer to listen to the checkbox's state change (selected/deselected) as mentioned by this example.
My problem is…

Adel Boutros
- 10,205
- 7
- 55
- 89