JRadioButton « Button « Java Swing Q&A





1. How do I get which JRadioButton is selected from a ButtonGroup    stackoverflow.com

I have a swing application that includes radio buttons on a form. I have the ButtonGroup, however, looking at the available methods, I can't seem to get the name of ...

2. How to manage two JRadioButtons in java so that only one of them can be selected at a time    stackoverflow.com

How to manage two JRadioButtons in java so that only one of them can be selected at a time? Is there any method in java to take care of this or ...

3. JRadio button with information link    stackoverflow.com

I want to have a set of JRadioButtons and next to each one a little 'i' image which when clicked will open a new window with information about the text next ...

4. Rich swing radiobutton    stackoverflow.com

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, ...

5. How can I customize the render of JRadioButton?    stackoverflow.com

I've created a JRadioButton subclass in which I override the paintComponent method like so:

@Override
protected void paintComponent(Graphics g) {
    g.drawImage(
        isSelected() ? ...

6. Java - pass value of one radio button that selected to another frame    stackoverflow.com

Is there any code that I can use to pass value of selected radio button to another frame? This is my code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class bookBatman extends JFrame implements ActionListener ...

7. What is the best way to determine what JRadioButton is selected?    stackoverflow.com

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) ...

8. JRadioButton: how to replace text by IconImage    stackoverflow.com

I want to replace the text in my radio button list by an icon I've tried this :

rotateButton = new JRadioButton(rotateIcon.getImage());
but this replaces the radio and text by the icon, I ...

9. Listening on ButtonGroup for "child" changes, and print selected JRadioButton's text    stackoverflow.com

What I want to is: Create an event that fires if the a JRadioButton contained in the ButtonGroup is selected, and then print the text there is on the JRadioButton.





10. JRadioButton that looks like JButton    stackoverflow.com

I'm trying to create a feature similar to that of Geogebra's toolbar: it has buttons that select tools, so only one can be selected at a time, but they ...

11. How to get the text value of JRadioButton    stackoverflow.com

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 ...

12. ActionListener can't reference array from public class?    stackoverflow.com

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 ...

13. JRadioButtons not appearing in JPanel    forums.netbeans.org

Hello. I'm working on a simple application, a program which is supposed to go through a predefined set of questions and get the user's response, after which it saves the answers to be accessed later. I'm doing this with a Java Desktop Application, with my code being run in the constructor of the View file. In the program there is a ...

15. JRadioButton!!!    coderanch.com

16. JRadioButton    coderanch.com





17. Problem with JRadioButton    coderanch.com

Hi Mihir, Gregg's logic is correct. However, humans are easily fooled. The following code will perform what you want. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class RadioTest extends JFrame { JRadioButton b1, b2, b3, b4; ButtonGroup bg; JButton butt1, butt2; public RadioTest() { super( "RadioBox Test" ); bg = new ButtonGroup(); b1 = new JRadioButton( "One" ); b2 = new ...

18. JRadioButtons w/a JButton    coderanch.com

Hi, i'm working on a project that requires 4 radio buttons and a jbutton to process the info. How do I set it up so that when a user chooses one of the radio buttons and hit the jbutton, the dialog box will alert the user to which radio button was selected? I have to use radio buttons! thanks in advance. ...

19. ButtonGroup with JRadioButton    coderanch.com

Is there a way to tell which radiobutton is select in a buttongroup .... isn't there a better way to find out which is select then this example if( rbDate.isSelected() == true ) { type = "1"; } if( rbEquip.isSelected() == true ) { type = "2"; }} if( rbNo.isSelected() == true ) { type = "4"; }

20. JRadioButton : Deselecting    coderanch.com

Initially, all buttons in the group are unselected. Once any button is selected, one button is always selected in the group. There is no way to turn a button programmatically to "off", in order to clear the button group. To give the appearance of "none selected", add an invisible radio button to the group and then programmatically select that button to ...

21. RadioGroup with JRadioButton    coderanch.com

Hi Guys, By default JRadioButtons are not selected, but when I select one radio button, and then press the clear button, they DONT come back to that formal status. I've searched through all the methods for RadioGroup but was unsuccessful in finding a solution to this problem (deselecting all the JRadioButtons) does anyone have a suggestion. thx, Ayman.

22. JRadiobutton    coderanch.com

23. JRadioButton question    coderanch.com

This might be a simple question for many of you. I'm a beginner in Swing... I have a menu with 4 option (4 RadionButton). What would be the code to know which one has selected. the screen has a OK key . I need to know which Radiobutton has selected when I press the OK key. Appreciate your input. thanks Raj ...

24. Text to the left of JRadioButton    coderanch.com

25. JRadioButton Help!    coderanch.com

I am using a database in my program and I want to be able to create a radio button which is named after a column name- obviously I can't specify the name of the column myself because the number of column may change for each database as well as the names for them. I have tried the following but get an ...

26. JRadioButton    coderanch.com

27. JRadioButtons and newlines    coderanch.com

28. How can I deselect JRadioButtons    coderanch.com

29. setState() with JRadioButton    coderanch.com

31. JRadioButton: actionPerformed problem    coderanch.com

Hello I have a simple form, with several radiobuttons, textfields and a submit button. Action listener is only set to the button. So after I press the button, I print out the information, but I get strange exception. Please help. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ControlPanel extends JPanel implements ActionListener { JTextField inputX; JTextField inputY; JRadioButton shape1; JRadioButton ...

34. Obtaining a JRadioButtons' ButtonGroup    coderanch.com

35. JRadioButtons in applet    coderanch.com

Originally posted by shaikat chakraborty: 1.how to hide the border of a JTextarea in an applet. 2.I have added four radio buttons and a Jbutton in an applet.if i select one radio button and press next button the four radio button is comming but the button which was selected remains selected even ihave used the method setSelected(false).

36. JTabbedpane with JRadiobutton?    coderanch.com

37. JRadioButton w/a JButton    coderanch.com

I'm trying to display a JDialog box that shows the choice the user made when a user selects the a radio button and hits the process button. Can someone point out whats wrong with the code? thanks import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SelectionFrame extends JFrame { private JLabel label, label2, label3; private JButton processButton = new JButton("Process"); private ...

38. JRadiobutton problem    coderanch.com

I created 2 radiobuttons, put it into a group box, and gave one of them a function called deposit ( a simple maths calculation) and the other, withdrawal.However, when i run the program, even when i don't select the 1st button, it automatically runs the deposit function, and when i click the other button, it doesn't execute the withdrawal function. I''m ...

39. How to give color for JRadioButtons?    coderanch.com

Hi friends, I need to give color for JRadioButtons (Not the background and foreground color, I need to create radio buttons as traffic signal lights). At a time any one of the buttons has the selected state. Is there any way to do that in JRadioButtons. Any help will be appreciable...... Thanks... Renjith M

40. JRadioButton    coderanch.com

how make radio buttons in order to make a single choice..? this is what i have. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class Vote extends JPanel { private JLabel component1; private JLabel component2; private JLabel component3; private JRadioButton movie1; private JRadioButton movie2; private JRadioButton movie3; private JLabel component7; private JRadioButton sport1; private JRadioButton sport2; private JRadioButton sport3; private ...

41. Using JButtons to move up and down a JRadioButton group    coderanch.com

Thank you for your advice, I will have a go with using an Array. I have managed to get it to work with a Cast/Switch: if (buttonPressed.equals(upButton)){ int currentButton = 1; currentButton ++; switch (currentButton){ case 1: radioButton1.setSelected(true); currentButton ++; break; case 2: radioButton2.setSelected(true); currentButton ++; break; case 3: radioButton3.setSelected(true); currentButton ++; break; case 4: radioButton4.setSelected(true); currentButton ++; break; case 5: ...

42. Accessing JRadioButton from another class    coderanch.com

Hi all, Im doing an applet with a clock and two radio buttons to select the background color. Im not sure how to access the radio buttons in the applet class, Im trying it with an ActionListener, and setActionCommand, but I cant make it work... Thanks in advance, Lyn import javax.swing.*; import java.awt.event.*; import java.util.*; public class Clock extends JApplet implements ...

43. Resizing issue using TitledBorder and JRadioButtons    coderanch.com

I have an that is using JXMultiSplitPane and I place several panels in a split pane to the right. I have the container panel added to a scroll pane and this fires when the split is adjusted however the JPanels that contain the JRadioButtons resize themselves slightly and cause the text of the radio buttons to clip? Is there a way ...

45. JRadioButton / BorderLayout Problem    coderanch.com

Hello, Using Eclipse I wrote a very simple program that displays three JRadioButtons. When I assign them to the South, the buttons stop being interactive, although in test cases I found that they will work(actionPerform). North always works (are interactive). Assigning CENTER displays to the EAST or WEST and sometimes are interactive. WEST doesn't work too, and leaving the assignment blank ...

46. Resizing JRadioButton    coderanch.com

47. Issue in JRadioButton    coderanch.com

Hi All, I have two jradiobuttons in JDialogbox. I have set functionality on each one. When I clicks on first radio button , a table displays in dialog box but when i clicks on second one , some labels and textfield appears. Both actions are overlapping each other. My requirement is that if i click on second radio button , table ...

48. Setting selected JRadioButton in ButtonGroup    java-forums.org

I'm not clear on what you're doing and perhaps more importantly, when. When are you checking this boolean variable and trying to set the state of your radiobuttons? In an ActionListener? I recommend you create a small compilable program that has nothing but to JRadioButtons added to a JPanel and a ButtonGroup and see if you can reproduce this problem so ...

49. JRadioButton Event Handling Help???    java-forums.org

Hello. I have been staring at this program and I cannot figure out what is wrong with it. Basically it is a stoplight whose lights are controlled by radio buttons. The program runs with no errors but the buttons do not work. I have a listener and have defined the actionperformed class but it is not working. I will post the ...

50. JRadioButton    java-forums.org

i am creating one swing application in that i am using JRadioButton in one form and that form showing the data into another form. but i have problem for insert a JRadioButton data into database and also for showing it..give me one of the simple example for that. i am using 4 JRadioButton in to one form and give different name ...

51. JRadioButton set object color    java-forums.org

[SOLVED] writing program which draws object(car) when mousepressed on the drawing panel. The user selects a radiobutton up top which specifies the color, then clicks and the cars are that color. I have the car and drawingpanel all set, just cant figure out how to have the jradiobutton in ButtonPanel setColor for objects on Drawingpanel, which then is read by the ...

52. JButton convert JRadioButton    java-forums.org

Hi, guys! could someone help convert the JButton to JRadioButton? this code also have some problems!! import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Food_Price extends JFrame { //Class Data; Food Food_Array []; //GUI Components JButton Foods_Buttons []; JButton Food1_Button = new JButton ("food1"); JButton Food2_Button = new JButton ("food2"); JButton Food3_Button = new JButton ("food3"); JButton Food4_Button = new JButton ...

53. JRadioButton and JButton    forums.oracle.com

Also, please get rid of worthless/redundant comments that do nothing but clutter the code and make it hard for us to read and understand. Your variables and method names should be self-commenting. For instance, naming one jradiobutton "radioButton" and the other "radioBButton" is bad practice. Better to name one loanFor7YrsRB and loanFor15YrsRB or somesuch.

54. JRadioButton in front of JPanel    forums.oracle.com

In the future, Swing related questions should be posted in the Swing forum. All Swing components are Containers so you can add any component you want to the radio button. The problem is by default it uses a null layout. So just set a layout manager on the radio button and you should be able to add any component to it. ...