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
4 answers

JRadioButton cannot be cast to JButton

I have actionPerformed() method which does two things: print out the radio buttons selected and set visibility of labels in another class. I get cannot be cast to error when the radio button is clicked. public void actionPerformed(ActionEvent e) { …
tesfa koli
  • 725
  • 2
  • 8
  • 11
1
vote
4 answers

ActionListener can't reference array from public class?

Why is public void actionPerformed (ActionEvent event), colorButton[] highlighted as cannot find symbol or variable? How do I debug it? I'm trying to make colorButton[] defined in public void actionPerformed (ActionEvent event) import…
V_Stack
  • 147
  • 2
  • 7
  • 15
1
vote
5 answers

How to get the text value of JRadioButton

I am creating a project in java. My Program has 80 JRadioButtons .... I need the get the text value of them.. Now these radiobuttons are added to ButtonGroup(each has 4 radio buttons)... I know how to get the text value from the radio button by this…
Tuhin Bhatt
  • 362
  • 2
  • 7
  • 19
1
vote
0 answers

With multiple yes/no radio buttons, do I have to create each instance?

I'm trying to make an app with a panel where it asks a question (whether an image contains humans, cars, or other objects... and more). Each question is answered with yes/no. I didn't want to make JRadioButton for each of the 'yes's and 'no's. So I…
ju09
  • 19
  • 3
1
vote
1 answer

How to link JRadiobutton to JButton for accurate Output

Background info: In my program I have a text file, that is read in, and contains a list of different book types with their respected info. I have successfully passed an array of these text values to my dictionary class. Inside the dictionary class,…
user14410420
1
vote
2 answers

Set different text of JRadioButton when it is enabled and disabled

I want to change text of the the JRadioButton when it is enabled or disabled. If the button is disabled it should should shows one text and when it is disabled it should show another text. Somehow I managed to make it change text when it is enabled.…
Sap Ashish
  • 19
  • 2
1
vote
1 answer

Change JLabel based on what user choose

I am task to do a simple order system. I want the JLabel (Amount: $0.00) show the corresponding amount on what the user picks for his burger and condiments. For example, if the user click on beef, the label will change into "Amount: $4.00", and when…
WiloWisk
  • 137
  • 3
  • 10
1
vote
1 answer

Creating GUI with sub menus

I'm trying to build a GUI which has submenus and may return to main menu and options, so far I've created a main menu but when I try to click the boxes nothing opens also only 4 items are showing when I have coded 5 items. Does anyone know a way…
mike123
  • 45
  • 2
1
vote
1 answer

JRadioButton is not show properly

I want to create a simple food ordering system, now i'm creating the interface of an order form. I used GridBagLayout for create the form layout, my problem is when I want to assign 3 radio button in same row, it's only show me 1 of the button....I…
Joseph
  • 55
  • 6
1
vote
2 answers

Listening to multiple JRadioButtons with one actionListener

I have two JRadioButtons that will be used to sort objects in a JList in various ways. They are both members of the same ButtonGroup. However, I'd like to listen to both buttons with one actionlistener and then iterate through them to see which one…
Austin H
  • 11
  • 1
1
vote
1 answer

Enabling ButtonGroup

quick and easy question for those who know how to use Java, is there a way to enable/disable Button-group ? i know i can set it on Radio Button, but if i have a Button-group of selected Radio Buttons, is there a way to set Enabled to all or i have…
user7943915
1
vote
1 answer

Java coding efficiency. JRadioButton objects and ItemListener interaction

I started coding in Java recently. I wanted to code a Window which contains: 1 Frame 1 Container 2 JPanel objects (To make sure to not confuse Panels, Container and Frame's object) 1 Scroll's object 1 JTextArea and 1 JTextField 1 JButtonGroup with…
Kyo
  • 25
  • 2
1
vote
3 answers

How to check if JRadioButtons are selected?

I tried if(jRadioButton1.isSelected() ||(jRadioButton2.isSelected()) { jGenderGroup.getSelection().getActionCommand(); } else { jGndrErrorLabel.setText("Select gender.") } But controller doesn't stop after highlighted line it does go…
user10738240
1
vote
2 answers

JRadioButton itemlistener not firing

Hello my Japplet is using a JComboBox and 5 JRadioButtons to draw and paint on the applet. Currently everything works except for my JRadioButtons which doesn't call the itemStateChanged() when a button is selected. So on the applet I can click on a…
Howard Ho
  • 13
  • 3
1
vote
1 answer

Clear Selection of RadioButtons

My application: user wants the object to move left with a particular speed - he/she chooses one radiobutton from moveToLeft ButtonGroup. But he/she changes his/her mind and wants the object to move right - he/she chooses one radiobutton from…
beechy
  • 101
  • 8