Questions tagged [jradiobutton]

JRadioButton is the Java Swing implementation of a radio button.

JRadioButton is a Java implementation of a radio button -- an item that can be selected or deselected, and which displays its state to the user. Used with a ButtonGroup object to create a group of buttons in which only one button at a time can be selected.

Relevant tutorials:

445 questions
1
vote
1 answer

Need help adding numbers everytime a JCheckBox or a JButton is checked off

Beef Button, Vegan Button and the others all have the prices beside them when opened. The others at the bottom (Mustard Ketchup and the other condiment also have the numbers) I just need to know how to add numbers to int TotalArgent out of all the 3…
1
vote
2 answers

Get the focus in a ButtonGroup of JRadioButtons to go to the currently selected item instead of first

I have some JRadioButtons in a ButtonGroup. These are all inside of a container, and there are other items on the group. Whenever I tab to the button group, the focus always goes to the first item in the group. However, I would much rather it go…
Pixelstix
  • 702
  • 6
  • 21
1
vote
2 answers

.setBackground() method is not working for JRadioButton

I'm writing a program that has a quiz element, and when the user gets an answer wrong, feedback is given. The question JFrame is made of a JLabel that has the actual question, and 4 JRadioButtons that have the different options (named rad1, rad2,…
1
vote
2 answers

How to use JRadioButtons to change a ComboBox

How can I use a RadioButton to select what appears in the combobox that is displayed after i.e. click (buttons(male) or (female)) and get a combo box drop down displaying either (combobox(Mr, master) or (Mrs,miss)) Ive spent the past few hours…
jammypotato
  • 65
  • 1
  • 7
1
vote
1 answer

Initially hidden radioButton dont be visible on event

I'm trying to make a component visible when i clicked on a radio button. RadioButton initialized hidden in initComponents method. I have put a mouseClickListener on radio button. It doesnt work if I initialize radioButton hidden. Works if i…
Erdel
  • 370
  • 3
  • 16
1
vote
1 answer

Need help getting JRadioButton to return Value to JTextField

My program is simulating voting in the Electoral College. Each state has a certain number of votes. I am having trouble with getting my buttons for each state to return the proper amount of votes to a total, and then printing that total to the…
user3712626
  • 115
  • 1
  • 9
1
vote
2 answers

background color and equal sized jradiobuttons

I have three radio buttons with background colors as shown below. I need to stretch all of them to same size so that the background colors are uniform(with same width).Tried adding setWidth(Dimension d) but it's not working. public class…
Pradeep
  • 1,193
  • 6
  • 27
  • 44
1
vote
2 answers

Rich swing radiobutton

Developing a desktop application based on Java + Swing I faced the problem of creating a radio button which instead of text next to it, should have and image or, say, another widget like a spinner. Clicking on the image or the spinner should select…
Hectoret
  • 3,553
  • 13
  • 49
  • 56
1
vote
1 answer

How to repopulate radio buttons postback in ASP MVC.5

How do I handle postback for radio buttons in ASP MVC 5? This tells how to do it for text inputs, but not radio buttons. With radio buttons, all radio buttons have the same names, so the model doesn't apply. Do I need a for loop of if statements, or…
abalter
  • 9,663
  • 17
  • 90
  • 145
1
vote
3 answers

Trying to get RadioButton.isSelected() to set the text of a label. Not working

This is my code: panel2.add(question1); panel2.add(true1); panel2.add(false1); panel2.add(labelAnswer1); panel2.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); if(true1.isSelected()) { …
acheema_
  • 7
  • 1
1
vote
1 answer

Changing items in jComboBox by clicking a jRadiobutton

Is it possible that the items in jComboBox change by clicking a jRadioButton? For instance: the first jRadioButton is selected and there are five options in jComboBox. When you click another jRadiobuttonfrom the same button group, the options from…
lol
  • 231
  • 1
  • 10
1
vote
1 answer

Have the selected radio button to display in text area

I'm making a program in netbeans that allows users to import their computer specs and I have 2 radio buttons and I want it when you would select the choice and when pressed display it would display your choice in the text area. I already have other…
Harpreet Sunner
  • 23
  • 1
  • 3
  • 9
1
vote
1 answer

How to save the selected JRadioButton from a ButtonGroup?

My program is trying to save the state of a ButtonGroup, so that it can be written to a file at the end of the program, or restored to the buttons if the user selects to go 'Back'. I have previously found this question: How do I get which…
1
vote
1 answer

Put JRadioButtons in new rows in ButtonGroup?

Is there a way to put JRadioButtons on new lines in ButtonGroups? I don't mean 1 button on every line but for example 2 buttons on one line and 2 buttons on the next but each in the same group like this for example: o Button one o Button two o…
1
vote
1 answer

Create boolean to show true when correct JRadioButtons have been selected

previous related question: Check which jRadioButtons have been selected if they have been created in a loop I now want to create a boolean, that when all correct JRadioButtons are selected from each row, this boolean will be true. To clarify, it…
AEkon
  • 119
  • 6