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

How do I combine a JTextField and a JRadioButton?

I would like to have a JRadioPanel with three options. The first two are hardcoded options, and I want the third to be an 'Other' button. I would like to have a JTextField instead of text as the title of that button, but I'm not sure how to do that.…
SaintWacko
  • 854
  • 3
  • 14
  • 35
2
votes
4 answers

startActivity dosen't work inside custom control (RadioButton)

I have a custom RadioButton class, i have placed it on Activity1. I am using its event "onClick" to open another Activity2. Below is the code: public class custom_radiobutton extends RadioButton{ Paint myPaint = new Paint(); private Context…
Yaqub Ahmad
  • 27,569
  • 23
  • 102
  • 149
2
votes
2 answers

Whenever I chose any radioButton it automatically selects the last one, What should I do?

Below is a short snippet of my code used in my Swing Application, Its an mcq application where I've used radioButtons as the mean to select the chosen option, However when I try selecting any option from 1-4, It automatically selects the last one.…
2
votes
6 answers

What is the best way to determine what JRadioButton is selected?

Currently I'm getting the selected button in this way, but I don't if this is the right/best method. MAybe there something more easy or object oriented than this. private int getFilterType(JRadioButton... buttons) { for (int i = 0, n =…
Renato Dinhani
  • 35,057
  • 55
  • 139
  • 199
2
votes
1 answer

Getting input from multiple button groups in Java

I have an array of question, an array of possible answers and an array of properties I want to find out by answering the questions String[] questions = new String[]{"Question1", "Question2", "Question3"}; String[] possibleAnswers = new…
Dobro
  • 31
  • 6
2
votes
2 answers

JComboBox within a JRadioButton

Say I wanted to add a JComboBox (or more general a JPanel, perhaps?) to a JRadioButton, what would be the easiest way to do it? Pseudo-wise, a radio button group where one of them includes multiple choices would look something like: O The weather O…
Juhl
  • 473
  • 4
  • 17
2
votes
1 answer

JRadioButton and action on them

I wrote this code to make the choices a user has to make to choose the game modes: JButton btnNewButton = new JButton("Start Game"); JRadioButton beginner = new JRadioButton("Beginner"); JRadioButton intermedie = new…
user7767366
2
votes
1 answer

GridBagConstraints Not Correctly Aligning JRadioButton Box

GridBagConstraints aren't working even with .weightx, .weighty, and .anchor specified. I need the component to be set in the top left but it keeps being set in the center of the screen. Below is the method I have for positioning the component.…
programmer
  • 71
  • 8
2
votes
3 answers

How do I put label under radio button within a panel with Java Swing/awt

There is 3 panels which I created as seen in the image. The first panel is the "From" panel, second is "To" panel, and third is the buttons panel. So the question is, how can I put a new line for the "Enter Temperature: [ ]" so that it will be…
Ojouk
  • 25
  • 1
  • 5
2
votes
0 answers

How to show text (not JRadioButton text) upon mouse hover a JRadioButton

--JAVA ECLIPSE-- Does anyone know how to show text upon mouse hover over radio button? I tried setToolTipText but it doesn't work.. Codes for RadioButton rdbtnPediatric = new JRadioButton("Pediatric"); rdbtnPediatric.addActionListener(new…
domster
  • 556
  • 2
  • 8
  • 26
2
votes
1 answer

How to get ButtonGroup of JRadioButton

In a project, I added ItemListener to a group of JcheckBox and JRadioButtons. And I want that when a user click on already selected JRadioButton, it gets deselected. For this only method I know is getting Corresponding ButtonGroup and then calling…
Sukhbir
  • 553
  • 8
  • 23
2
votes
1 answer

Why does my JRadioButton not work in this case?

I'm trying to create a screen to change the options of my game, so I'd a problem that using a JRadioButton works in a case and not in the other, and I didn't understand why... Does anybody know what happened? package com.damas.screen; import…
2
votes
1 answer

JRadioButton selection doesn't show on GUI until visible in Windows LaF

I'm currently working on a project that requires the state of a JRadioButton to change when the record being viewed is updated. We've had a few clients complain to us that when the record changes, if the JRadioButton is off-screen, it won't be…
Kuronai
  • 23
  • 1
  • 4
2
votes
1 answer

How to insert value of radio button into database in java?

i have 2 JRadioButtons called Male & Female in my design.and at the end of source code,I declared a private String variable called gender.then in in Jradiobutton action perfomed events i have assigned as this, In jradio button1 action performed…
user5178776
2
votes
2 answers

Adding value to JRadioButton

I'm trying to make a sort of simple soccer simulator. This is the code I created after watching tutorials and i know its pretty bad. All i want to do is add a value to the team, like 1 for the best team and 10 for the worst, and when i choose a team…