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
0
votes
2 answers

Java Gui Radiobutton to stop playing

EDIT: I fixed my code and managed to get the song to work on the first radio button. But now If i unclick the button, the song will just start over instead of stopping. How do I make the song stop once the button has been clicked again, i tried a…
0
votes
3 answers

Selecting radio buttons to make text appear

Using radio buttons displayed on a panel, is it possible to select the radio button and then display some text on the panel explaining what the user has selected? So here is a list of radio buttons public void RadioButtons() { btLdap = new…
user3146973
  • 5
  • 1
  • 5
0
votes
2 answers

ButtonGroup null pointer exception

I've created a method that will clear any previous selections made to my ButtonGroup that is comprised of radio buttons public void resetRadioButtons() { if (group.getSelection() != null) { group.clearSelection(); } else { …
Jared
  • 33
  • 1
  • 8
0
votes
1 answer

Register JPanel in radioButtonActionPerfomed

Can I catch the panel name from ActionListener? Here is some code: void models (int paneNum, int tabNum, String eQuery, String str, String title) throws SQLException { intoModels[paneNum] = new JPanel(); …
nemelianov
  • 911
  • 1
  • 7
  • 15
0
votes
3 answers

Adding JRadioButton to Group

I have some problems with adding JRadioButton to ButtonGroup and then to JPanel, here is some code: void modelsRadio () throws SQLException { JPanel modelsRadioPanel = new JPanel(); Statement statement = db.setConnection(); ResultSet…
nemelianov
  • 911
  • 1
  • 7
  • 15
0
votes
1 answer

JRadio Buttons and Font change

I am having a little bit of trouble trying to get my JRadio Buttons to change the color of the text depending on what the player chooses. I am just making the GUI for the game setup page. Something like, choose your army, followed by choose the…
0
votes
4 answers

Reading Selected Radio Button on button click

I am trying to get the value of the selected radio button on button click. This is what I managed to do but I am getting null as a result. //Buttons Declared JRadioButton choice1 = new JRadioButton("Choice 1"); JRadioButton choice2 = new…
user3274252
  • 57
  • 1
  • 6
0
votes
1 answer

Component not appearing when adding to panel

So I'm trying to create a series of radio buttons and check boxes that are displayed as follows: Radio Button Check Box Radio Button Check Box Radio Button However, I'm still in the learning process for java and I was…
user3352349
  • 177
  • 2
  • 4
  • 16
0
votes
4 answers

How come my JRadioButtons labels are "..." and not text I want?

I don't know why each button isn't displaying the text i want, and why it is displaying "..." ButtonGroup operations = new ButtonGroup(); JRadioButton[] buttons = new JRadioButton[2]; String[] buttonLabels = {"Male", "Female"}; for (int…
Bauer
  • 159
  • 4
  • 13
0
votes
2 answers

Adding a radio button group to the screen

So I'm creating a calculator that calculates BMR & TDEE. I'm having issues when I run the code because everything shows up, except my radio button groups. Can anyone tell me what I need to add/what I'm doing wrong to get them to show up on the…
danih
  • 19
  • 5
0
votes
2 answers

How to hide a Text Field when a radio button is selected/not selected?

I'm writting a program to encript data. It has a JTextArea to edit text, but I want to choose if I save it encripted or in plain text. For this I created a JDialog that appears when the save button is clicked. It contains two radio buttons: one to…
Junior
  • 17
  • 1
  • 6
0
votes
1 answer

Radio buttons disappearing

This Java code is using Swing. I am trying to generate a form so that Swing basic would be covered in it. It has label, button, textfield but radio button is not working. Please tell me the errors in it. Is it because I am not adding radio buttons…
Eager
  • 1
  • 2
0
votes
2 answers

get type of a component in a JPanel

I have a foreach loop that iterates all components in a jPanel, and I want to get the type of a components and check if it's a JRadioButton. this is the code I tried: for (Component c : ((Container)jPanel1).getComponents() ) { …
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191
0
votes
3 answers

JRadiobutton selection not showing

Java: I have a 3 JRadioButtons added to a JPanel, which is added to a GraphicsProgram. When I Run the program, I can select the radiobuttons (when I click the buttons, they do function). However, the JPanel doesn't show the new selection. In other…
Raymond Zheng
  • 119
  • 1
  • 10
0
votes
2 answers

Using JRadioButton for selecting gender

I am developing a Java desktop app.I need to implement gender selection (male or female) using JRadioButton .I have two JRadioButttons .But my problem is that here I can select both JRadioButtons.How can i restrict this ? that is I need to select…
RAJIL KV
  • 399
  • 1
  • 7
  • 24