Radio Buttons problem

Hi i ahve developed a GUI with 2 toggle buttons options[0] and options[1],I have also created an "OK" Button.the programming is working fine ,but i now want to implement the action performed method.The user must select which option he/she wants and then click the ok button.I am not sure how to do this in the action performed method.the first button,cancels the ticking of any radio button (clears the readio buttons)and the second bottun exits
here is my code so far
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class LogOut extends JFrame implements ActionListener{
JRadioButton[] options = new JRadioButton[2];
public LogOut(){
super("Log Out?");
setBounds(225,125,140,190);
setDefaultCloseOperation(JFrame.Exit_ON_Close);
options[0] = new JRadioButton("Log Out");
options[0].addActionListener(this);
options[1] = new JRadionButton("Cancel");
options[1].addActionListener(this);
JPanel pane = new JPanel();
ButtonGroup group = new ButtonGroup();
for(int i = 0; i < options.length; i++){
group.add[options[i]);
pane.add(teams);
setContentPane;
show();
public static main void(String[] arguments){
LogOut lo = new LogOut();
public void actionPerformed(ActionEvent evt){
Object source = evt.getSource()

I understood it as you select a check box, and then when you click the button, it should do something based on what you have selected.
So if you continue with the code I posted,
public void actionPerformed(ActionEvent e) {
  // the button has been clicked:
  for (int x = 0; x < options.length; x++) {
    if (options[x].isSelected()) {
      // radio button at index 'x' has been selected.
      switch (x) {
        case 0: {
          options[x].setSelected(false); // the only radio button checked..
          break;
        case 1: {
          System.exit(0);
          break;
        default: {
          System.out.println("Not defined"); // will only occur if you add more radio buttons later.
      return;
  System.out.println("No radio buttons have been selected");
}Or is what you really want, an action to start at the moment that you select/unselect a radio button without pressing the OK button?

Similar Messages

  • Selection screen radio buttons problem

    How enable and disable the radio button in selection screen?

    Hi Ram,
    Try using the below code it may useful for solving your problem .
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-014.
    SELECT-OPTIONS kunnr FOR komg-kunnr.
    SELECT-OPTIONS waerk  FOR komg-waerk MODIF ID def .
    SELECT-OPTIONS pltyp FOR komg-pltyp MODIF ID abc.
    SELECT-OPTIONS matnr FOR komg-matnr MODIF ID abc.
    SELECT-OPTIONS vkorg FOR a007-vkorg MODIF ID jkl.
    SELECT-OPTIONS vtweg FOR a007-vtweg MODIF ID jkl.
    SELECT-OPTIONS spart FOR a007-spart MODIF ID jkl.
    PARAMETERS datum LIKE rv12l-datint DEFAULT sy-datum.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-015.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS:r3 RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND ucom.
    SELECTION-SCREEN COMMENT 10(20) text-018.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS:r1 RADIOBUTTON GROUP g1.
    SELECTION-SCREEN COMMENT 10(20) text-016.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS:r2 RADIOBUTTON GROUP g1.
    SELECTION-SCREEN COMMENT 10(20) text-017.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS:r4 RADIOBUTTON GROUP g1.
    SELECTION-SCREEN COMMENT 10(20) text-022.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b2.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF r1 EQ 'X'.
          IF screen-group1 = c_jkl.
            screen-input = 0.
            screen-invisible = 1.
          ENDIF.
        ENDIF.
        IF r2 EQ 'X'.
          IF screen-group1 = c_def OR screen-group1 = c_jkl.
            screen-input = 0.
            screen-invisible = 1.
          ENDIF.
        ENDIF.
        IF r3 EQ 'X'.
          IF screen-group1 = c_abc OR screen-group1 = c_def.
            screen-input = 0.
            screen-invisible = 1.
          ENDIF.
        ENDIF.
        IF screen-group1 = c_ghi.
          screen-input = 0.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    Regards,
    Jana

  • Radio Button Problem in Webdynpro For Java

    Hi to all,
                   I am new to Webdynpro. I want to create four Radio buttons which will fetch the data from the RFC. I have created a Context value node called options and created four value attribute under that options node.
    The Problem is if i use the Radio button group by index i could map only one attribute at the "texts" field of Radio button group. how do i map the other values.
    or Is there any other way of using Radio button for such of requirements.
    Please if any one bring me the Solution to this issue it would be more help ful to me.
    Thanks in advance...
    Regards,
    Malar.

    Hi Thenmalar,
    If you want to have four radiobutton then you need to have only one value attribute within the node.
    Assume you want to have 4 radio buttons named one, two, three and four
    1. Create a value node called Radio and create a value attribute within this node called Value
    2. Bind this attribute to the radiobutton group.
    3. Define the values of these radiobuttongroup at runtime(in WDDoInit() method of the view)
    IPrivate<viewname>.IRadioElement ele = wdContext.nodeRadio().createRadioElement();
    ele.setValue("one");
    wdContext.nodeRadio().addElement(ele);
    IPrivate<viewname>.IRadioElement ele1 = wdContext.nodeRadio().createRadioElement();
    ele1.setValue("two");
    wdContext.nodeRadio().addElement(ele1);
    IPrivate<viewname>.IRadioElement ele2 = wdContext.nodeRadio().createRadioElement();
    ele2.setValue("three");
    wdContext.nodeRadio().addElement(ele2);
    IPrivate<viewname>.IRadioElement ele3 = wdContext.nodeRadio().createRadioElement();
    ele3.setValue("four");
    wdContext.nodeRadio().addElement(ele3);
    You will get the values one, two, three and four at runtime.
    Regards,
    Murtuza

  • Radio Button Problem

    I have placed a radio button according to http://thepeninsulasedge.com/frank_nimphius/2007/11/07/adf-faces-radiogroup-is-table-column/ .It works when I use it independently.But I have a readonly table of the Employee table on click of this I have a panel Accordin inside which I have places ADF Form the value gets populted when I have a textbox But when I replace this with the radio button according to the link the value does not get set.What may be the problem.

    Hello,
    the value of a radio group is indicated in the RADIO_GOUP item (wich properties are defined like DATATYPE, LENGTH and INITIAL VALUE).
    When you click on an option button, it is the radio group that store the value.
    Francois

  • Radio button problem in jdeveloper.

    Hello all..
    I am new to Jdeveloper and infact to CSS and stuffs. In a fix now regarding <tr:selectOneRadio> styling.
    For brevity..
    <tr:selectOneRadio styleClass="radioClass" contentStyle="font:25px bold;">
    the above is the code i have,
    but the problem is the radio button font is not changing even after giving separate style class.
    Can anyone give a solution, might be a simple one, but it ll be wonders lot for me!! [:)]
    First post in the forum, hope to get a sol..
    Appreciate ur help.. Thank you.

    Hi brano... thanks for quick response...
    The issue still exists here..
    Actually this perticular line contentStyle="font:25px bold;* inside <tr:selectiononeradio> seem not to render any effect for me.
    <tr:panelFormLayout styleClass="id">
    <p>
    <tr:outputLabel inlineStyle="position:relative; font:35px bold;"
    value="Claim number:"/>
    <tr:inputText contentStyle="height:45px; font-size:35px;"
    columns="25"></tr:inputText>
    </p>
    <p>
    <tr:outputLabel inlineStyle=" font:35px bold; position:relative;"
    value="Claim on my policy:"/>
    <span style="font:20px bold;">
    <tr:selectOneRadio layout="horizontal" contentStyle="font:25px bold;"
    id="radioYN">
    <tr:selectItem label="Yes" id="Y"
    value="Yes"/>
    &amp;&amp;nbsp;&amp;&amp;nbsp;
    <tr:selectItem label="No" id="N" value="No"/>
    </tr:selectOneRadio>
    </span>
    </p>
    <p>
    <tr:commandButton inlineStyle="width:300px; font-size:30px;"
    text="continue"/>
    </p>
    <p></p>
    </tr:panelFormLayout>
    check out the code for ref..
    Thank you...

  • Select options and radio button problem

    Hi All,
    In selection screen I have a select option and two radio button default is disable when I input value on select option, it will enable radio button. How can I do this?
    Thanks.
    mlai

    Please go through the below code and reward points if u find it useful:
    tables : pa0000.
    selection-screen begin of block b1 with frame title text-001.
    select-options : s_pernr for pa0000-pernr.
    parameters : r1 radiobutton group g1 modif id abc.
    parameters : r2 radiobutton group g1 modif id abc.
    selection-screen end of block b1.
    at selection-screen output.
    if s_pernr[] is initial.
    loop at screen.
    if screen-group1 = 'ABC'.
    screen-invisible = 1.
    modify screen.
    endif.
    endloop.
    else.
    loop at screen.
    if screen-group1 = 'ABC'.
    screen-invisible = 0.
    modify screen.
    endif.
    endloop.
    endif.
    Thanks
    Vasu

  • Radio button problem in webdynpro abap

    Hi Guys,
    In the selection screen i have 2 radio buttons PO and RP.
    user is allowed to select either of the one so i have created 1 radio button group.
    scenario 1:
    when user clicks on radio button 1 and then click the submit button.
    now he wants to change his selection so he again enter and click the radio button 2 and click on subnit button.
    if he goes again he can see the radio button 2 selected.so it is working fine.
    Scenario 2:
    when user clicks on radio button 2 and then click the submit button.
    now he wants to change his selection so he again enter and click the radio button 1 and click on subnit button.
    if he goes again he can see the radio button 2 selected.so it is not working fine.
    The coding is as follows:
    on action submit i have writtent the following code
    IF ls_iohncust_values-repplanonly IS NOT INITIAL.
                 IF ls_iohncust_values-repplanonly EQ 'PO'.
                   ls_profgen_custval-cust_attr      = 'REPONLY'.
                   ls_profgen_custval-cust_value     = 'X'.
                 ELSEIF ls_iohncust_values-repplanonly EQ 'RP'.
                   ls_profgen_custval-cust_attr      = 'REPPLAN'.
                   ls_profgen_custval-cust_value     = 'X'.
                 ENDIF.
               ENDIF.
    Kindly let me know why scenario 2 is not working.

    Hi Vijay,
    IF ls_iohncust_values-repplanonly IS NOT INITIAL.
                 IF ls_iohncust_values-repplanonly EQ 'PO'.
                   ls_profgen_custval-cust_attr      = 'REPONLY'.
                   ls_profgen_custval-cust_value     = 'X'.
                 ELSEIF ls_iohncust_values-repplanonly EQ 'RP'.
                   ls_profgen_custval-cust_attr      = 'REPPLAN'.
                   ls_profgen_custval-cust_value     = 'X'.
                 ENDIF.
        ENDIF.
    As I can see there is no such issue in selecting data in secord scenario. It might be the case that it's not getting cleared so you can just clear your node ls_iohncust_values-repplanonly after your endif on submit action.

  • Radio Button problem when using Logical Databases.

    Hi,
    I have a report that uses logical database PCH.  I'd like to default the reporting period radio button so that when the report is run it is defaulted to today.
    The name of the screenfield is PCHZTR_D so I set
    PCHZTR_D = 'X'. 
    in the initialisation event but this doesn't work.
    Any suggestions how I can get the reporting period to default to 'today' programmatically.
    I don't want to use a variant.
    Thanks,
    Paul

    Try doing it in the AT SELECTION-SCREEN output Event.
    report zrich_0001.
    nodes: objec.
    <b>at selection-screen output.
    PCHZTR_A = space.
    PCHZTR_D = 'X'.</b>
    REgards,
    Rich HEilman

  • Can't See Shared Music (Not radio button problem!)

    I haven't been able to see Shared Music on my college network since I reinstalled Windows XP (around iTunes 4.8). I don't know what settings have changed.
    I now have the latest iTunes, the radio buttons are on. I heard about opening up a port, and bonjour service. I'm not sure how to execute those solutions.
    Thanks for your time,
    Connie

    Although that was a very helpful hint that I can in fact play Mac's iTune Music on iPad without syncing, it's not solving my primary issues, which are:
    1. I bought some music via iTunes on iPad and I can't get them to Mac, because that Shared label is not present in my Mac iTunes
    2. I want some of my Mac iTunes music to sync to iPad anyway, because I want to play it also when not being on home share network.
    3. When I synced iPad, many apps have been removed from it and are not there anymore, but appear in Mac's iTunes in that Apps section under iPhone, iPod touch and iPad Apps, but are not below in iPad Apps - I don't know how to get them back to iPad and how to prevent this to happen again
    These are maybe trivial questions, but I wasn't able to find answers and don't have so much time to search more.
    Thanks.

  • Radio Button problem Please Help

    I created radio button in the page
    OAMessageRadioButtonBean radio = new OAMessageRadioButtonBean();
    I dont want to show radio button sometimes, I couldnt find showradiobutton(false) method or enabledradiobutton(false) something like that how can I do this, Please Help....

    Hi.
    Use this code in Process Request:--
    OAMessageRadioButtonBean mButton = (OAMessageRadioButtonBean)webBean.findChildRecursive("Id of RadioButton");
    mButton.setRendered(false);
    If you want to hide it depending upon some condition then use PPR.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Forms 5.0 - Radio button problem

    In Forms 5.0,I have created a entry screen which consists a
    radiogroup with 2 radio buttons. In new-form-instance trigger, I
    have written
    execute_query ;
    last_record;
    It shows me the last record but it shows my radio group with no
    button selected.
    If I go back to the previous record, it shows me the record with
    one of the radio button selected.
    My question is why it does not show radio button selected when my
    when-new-form-instance trigger fires ?
    null

    Hi Shamshad,
    Please check the property sheet of the radio button, I remember
    there is a option for specifying the value for a selected radio
    button. I had worked with Oracle 4.5 some time ago but not with
    version 5, so please correct me if there is no option of doing
    so.
    Krishna
    Shamsad Khan (guest) wrote:
    : In Forms 5.0,I have created a entry screen which consists a
    : radiogroup with 2 radio buttons. In new-form-instance trigger,
    I
    : have written
    : execute_query ;
    : last_record;
    : It shows me the last record but it shows my radio group with
    no
    : button selected.
    : If I go back to the previous record, it shows me the record
    with
    : one of the radio button selected.
    : My question is why it does not show radio button selected when
    my
    : when-new-form-instance trigger fires ?
    null

  • Wierd Radio Button Problem

    can we set the value of a radio button at runtime?
    Suppose there are two radio buttons: Yes and No.
    Suppose a user chooses Option1 from a drop down list, then Radio button Yes should be highlighted, if the user chooses Option 2 from the drop down list, then the Radio button No should be highlighted.
    I am trying the following code but its not working:
    if (option.rawValue == Option1)
    radioButton1.rawValue = true;
    else
    radioButton2.rawValue = true;
    Is it the rawValue property of radio button that I should use or something else?
    I am really stuck on this. Any help would be highly appreciated

    It's called RadioButtonList a "group" of radio options.
    In your example, in one RadioButtonList, you have 2 options: Yes and No. You should specify a value for each option in the RadioButtonList's Binding tab.
    By doing this you're able to change the value at run time:
    form1.subform.RadioButtonList.rawValue = "1"; // for Yes option.
    an so on.
    I hope this helpful.
    Diego

  • Radio Button problem (not yet solved !!! --- Top Urgent )

    In Forms 5.0,I have created a entry screen which consists a
    radiogroup with 2 radio buttons. In new-form-instance trigger, I
    have written: execute_query ;: last_record;
    It shows me the last record but it shows my radio group with no
    button selected.: If I go back to the previous record, it shows
    me the record
    with : one of the radio button selected.
    My question is why it does not show radio button selected when my
    when-new-form-instance trigger fires ?
    Please note : Property palette of Radio Group & Radio buttons
    have been correctly assigned .
    null

    Shamsad Khan (guest) wrote:
    : In Forms 5.0,I have created a entry screen which consists a
    : radiogroup with 2 radio buttons. In new-form-instance trigger,
    I
    : have written: execute_query ;: last_record;
    : It shows me the last record but it shows my radio group with no
    : button selected.: If I go back to the previous record, it shows
    : me the record
    : with : one of the radio button selected.
    : My question is why it does not show radio button selected when
    my
    : when-new-form-instance trigger fires ?
    : Please note : Property palette of Radio Group & Radio buttons
    : have been correctly assigned .
    Shamsad Khan,
    In Forms5.0, try setting Mapping of other values properties.
    regards.
    null

  • Having problem to get the value from radio button

    i am doing my double module project for my degree course and i am also a newbie in JSP. Hope there is someone can help me to solve this problem. Now, i set the value of a radio button to "don't smoke", "smoke lightly", and "smoke heavily". Then i use request.getParameter ("smoking behavior") to get the value selected by the user, but the result is only "don't" or "smoke", which the character after spacing will be not be retrieved. I dun know how to solve it, so can any expert here help me to solve this problem? Thanks for helping.

    Why do you have to use whitespace. If your radio button group is name smokingBehavior - no whitespace, wouldn't it just make sence to have values of don't, lightly and heavily. This would solve the problem easily. If your teacher is being a pain in the a&!, and requires you to use whitespace for your naming variables I guess you could insert %20 between the two words and unescape the value on the server side. This seems like a lot of unnecessary work and a silly solution - good luck!

  • Facing Problem in Configuring Radio buttons

    Hi,
    I have a requirement as follows:
    There are two  fields:
    A1 - Input field
    R1 - Radio button field
    Now I need to display the fields as mentioned below,  in ONE ROW of left Panel
    I to J                   K to M                          N to P
    A1.label            A1.field value             R1 (2 radio buttons with no label)
    When I am trying to do this, I am getting an error for Radio button field, saying:
    Element must cover the entire panel
    Error in property value
    Could you please help me out to solve my issue..
    Thanks for the needful..
    Sandeep

    Hi Dharma,
    My Problem is solved..
    Well the weird part is, when I click on Apply button, it has shown the errors as mentioned above. I thought, it won't allow me to save the configuration.  However as soon as click on SAVE button, all the config changes have been updated successfully.
    I am not sure, why SAP is showing those errors, when we are able to save the config successfully....
    Thanks for your reply...
    Cheers
    Sandeep

Maybe you are looking for

  • Can't see Windows computers in 'Shared' in Finder

    I have searched but can't find the definitive answer to this. On my network, I have 4 Windows PCs/laptops and my Mac.  All the Windows computers can see and access my Mac, but none of them show up in the Shared sidebar item in Finder on my Mac. The w

  • What's with having to change passwords each time one error is made entering it?

    So I entered what I believe was the correct itunes store account password and it says invalid.  I try again and it suddenly locks me out, now I have to create an entirely new password (one that has not been used in over a YEAR) and a bunch of other r

  • Photo sizes on iPhone

    If I want to prepare photos NOT taken on my iPhone for transfer to the iPhone to create albums/slide shows for friends: 1) what size should the photos be--(dpi resoulution and dpi size), and 2)  is there a good iPhone slide show app?  (Like the one i

  • Qosmio F30-117: How to switch Bluetooth on?

    how to switch blue tooth on, on qosmio f30-117. As software is preinstalled for blue tooth. Message was edited by: jdukhi

  • Workaround for scanner for HP 3055 running OSX Lion 10.7?

    Do you have a workaround for the HP Laserjet 3055/3050 all-in-one scanning ability for Mac OSX Lion 10.7? I am hitting the wall trying to find out how to enable the scanner to work? This question was solved. View Solution.