How to enable a disabled radio button????

Hi here is the problem i have, i have a number of radio buttons contained in a buton group, all the buttons bar the first one are disabled. The buttons are all drawn on a JPanel. What i want to be able to do is once the enabled button has been selected, I want to enable the next button in the gropu and also then disable the one that was previously enabled. Is there any way i can do this, below is the code i have for setting the group up, and trying the above probelm. Any help much appreciated Thanks.
/* Function creates a radio button and adds it to the button group */
     public JRadioButton getRadioButton(String myString, boolean val)
          JRadioButton myButton=new JRadioButton(myString);
          myButton.setActionCommand(myString);
          myButton.addActionListener(myListener);
          myButton.setEnabled(val);
          group.add(myButton);
          return myButton;
//adds the radio buttons to the panel, for each transition */
     public void addTranPan()
               for(int i = 0; i < dCreate.char2.size(); i ++)
               if (i == 0) mPanel.add(getRadioButton(dCreate.char2.elementAt(0).toString(),true));
               else
mPanel.add(getRadioButton(dCreate.char2.elementAt(i).toString(),false));
public void ChangeButtonState()
Component [] components = getContentPane().getComponents();
          for (int i = 0; i < components.length; i++)
               Component c = components;
               if (c instanceof JRadioButton)
               JRadioButton rb = (JRadioButton) c;
               rb.setEnabled(false);
               if (c.getName().equals(ch)) //find button to enable
               JRadioButton rb = (JRadioButton) c;
               rb.setEnabled(true);
               break;
          mPanel.repaint();

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class sol21 extends JFrame implements ItemListener {
JRadioButton
   radio1 = new JRadioButton("One"),
   radio2 = new JRadioButton("Two"),
   radio3 = new JRadioButton("Three"),
   radio4 = new JRadioButton("Four");
  JRadioButton[] radios = {
    radio1, radio2, radio3, radio4
  int INITIAL_ENABLED = 0;
  public sol21() {
    ButtonGroup group = new ButtonGroup();
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5,0,5,0);
    gbc.anchor = gbc.WEST;
    gbc.gridwidth = gbc.REMAINDER;
    for(int j = 0; j < radios.length; j++) {
      radios[j].addItemListener(this);
      group.add(radios[j]);
      panel.add(radios[j], gbc);
      if(j == INITIAL_ENABLED)
        continue;
      radios[j].setEnabled(false);
    setContentPane(panel);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(300,200);
    setLocation(300,200);
    setVisible(true);
  public void itemStateChanged(ItemEvent e) {
    JRadioButton button = (JRadioButton)e.getItemSelectable();
    if(e.getStateChange() == ItemEvent.SELECTED) {
      int index = 0;
      for(int j = 0; j < radios.length; j++)
        if(radios[j] == button)
          index = j;
      radios[(index + 1) % radios.length].setEnabled(true);
      if(index == 0)
        index = radios.length;
      radios[(index - 1) % radios.length].setEnabled(false);
  public static void main(String[] args) {
    new sol21();
}

Similar Messages

  • Control disable radio button

    is there any resource or sample that shows how to disable radio button from action class? I am trying to avoid java code inside the JSP page. I know that the attribute disable="false" disables radio button, but I am wondering if there is a way to set that attribute in the action class. If someone knows, please teach me how to do it. It would be very grateful.

    no, cuz that disable="false" is Javascript, which runs in the client side and has nothing to do with the server side.

  • How to Enable and Disable column in Table Control.

    Hi all,
    I want to make certain column of Table control as Enable or Disable on Button action.
    Enable means ready for input and Disable means not ready for input.
    Please send me sample code.
    Thanks in advance.

    Hi Vipin,
        You have to loop through the table columns to set the properties in the PBO of your screen.
    Here is the sample solution.
    delcare a workarea for the columns in the table control in your top include.
    Table Control .
    CONTROLS: TAB1 TYPE TABLEVIEW USING SCREEN '0100'.
    DATA: WA_COLS LIKE LINE OF TAB1-COLS.
    in your screen
    PROCESS BEFORE OUTPUT.
      MODULE INTIALISE_100.
    *&      Module  0100_INTIALISE  OUTPUT
    MODULE INTIALISE_100 OUTPUT.
        LOOP AT TAB1-COLS INTO WA_COLS.
          WA_COLS-SCREEN-INPUT = 1.
          MODIFY TAB1-COLS FROM WA_COLS TRANSPORTING SCREEN-INPUT.
        ENDLOOP.
    ENDMODULE.                 " 0100_INTIALISE  OUTPUT
    modify the screen-input property as required for the table control columns.
    Please provide points if helpfull.....
    Thanks,
    Karthik
    Message was edited by: Karthik
            Karthikeyan K

  • How to use Checkbox  and radio buttons in BI Reporting

    Hi BW Experts,
       My Client has given a report in ABAP format and the report has to be develop in BI.It contains Check boxes and the radio buttons. I don’t know how to use Checkboxes and radio buttons in Bex.For using this option, do we need to write a code in ABAP.Please help on this issue.
    Thanks,
    Ram

    Hi..
    Catalog item characteristic
    - Data element
    - Characteristic type
    Entry type
    List of catalog characteristics
    Designer
    Format (character)
    Standard characteristic
    Alternative: Master characteristic
    (used for automatic product
    assignment)
    Simple entry field
    Alternatives:
    Dropdown listbox or radio button
    list

  • How do I include the radio-button items on a second column as possible answers to the question?

    Using Adobe Acrobat Pro X, we created a fillable PDF from an existing PDF.
    One question can be answered by choosing one of four choices (radio buttons). The answers are laid out in a 2-by-2 arrangement.
    When Acrobat Pro converted the PDF into fillable format, it thought that the radio-button answers on the second column are not part of the question.
    How can I manually override Acrobat and make choices 3 and 4 part of the question.
    Please click attached screenshot for better zoom.

    George,
    i am the OP. I mistyped my email address and cannot log in to my original account.
    Thanks for your reply.
    How do I give each radio button the same name but unique button values?
    I right-clicked the first radio button, chose Properties (Ctrl+I).
    I copied the name: "What is your personal net worth in Canadian dollars including spousecommon law partner if applicable".
    I clicked Close.
    I then went into the Properties dialog window of the third radio button, which is one of the ungrouped choices. I pasted the name [What is your personal net worth in Canadian dollars including spousecommon law partner if applicable]. I then clicked Close.
    I get an error message pop up:
    A field of a different type already uses this name. Please choose a new name for the field, or change the field type to match the existing field with this name.
    What must I do now?
    Thanks.

  • How to enable my disabled I pad

    How to enable my disabled iPad

    If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup).
    If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.
    You may have to force iPad/iPod into Recovery Mode
    http://support.apple.com/kb/ht4097

  • How to define  parameters with radio button

    HI
      How to define  parameters with radio button, but that radio button should display in front of the variable name not after variable name. and under that radio button variable I hve to define parameters, select-options and some other radiobutton varibles.
            I don't know how to paste figures here, otherwise i will provied u the figure for more details.
    Regards.

    PARAMETERS : r1 RADIOBUTTON GROUP radi.
    Go to --> text elements --> selection text
    R1    <your text>
    You can change the program selection screen lay out in screen painter (se51) .
    screen number for your selection screen is 1000.
    Regards,
    Santosh reddy
    Edited by: Santosh Reddy on Dec 9, 2008 11:21 AM

  • How to create dropdown box, radio button,check box in wad

    Hi,
    How to create dropdown box, radio button,check box in wad.
    Thanks,
    cheta.

    Cheta,
    This are all standard Web Items in the WAD. Drag them onto your template and then make the changes you need to them in their Properties.
    Regards
    Gill

  • Enabling and disabling the button in the multi record block

    hi all,
    i am using
    Forms [32 Bit] Version 6.0.8.24.1 (Production)
    Oracle Database 10g Release 10.2.0.1.0 - Production
    i have a multi record block each block contains a button(button is to approve the record in terms of changing the status)
    i have the items like date,remarks and button
    the button should be enabled if the remarks is not null otherwise it should be disabled.
    for this in pre-record trigger i have written
    if :record is null then
       set_item_property('button',enabled,property_false);
    else
          set_item_property('button',enabled,property_false);
    end if;what problem is enable and disable is impacting on all the buttons in the block. in other words if first record's remarks is null then all the records button is disabled. if first record's remarks column is not null then all the records of the button column is enabled.
    i have to make enable and disable the button for the corresponding record.that means if first record's remarks column is not null then only first records button should be enabled others should be disabled.
    Thanks..

    You need to set the No. of items displayed to 1 as Ammad had said, additionally you can set the X and Y Position (Just Y will do and having fixed X) of the button depending upon the current record.
    can u explain this part alone bit more (setting the position of x and y)You need to calculate the variable Y_POS depending upon the current position of the cursor that is the current record.
    You can find the current record Y_POS using combination of
    V_CURRENT_RECORD := :SYSTEM.CURSOR_RECORD;
    V_TOP_RECORD := GET_BLOCK_PROPERTY ('BLOCK_NAME', TOP_RECORD);
    V_ITEM_Y_POS := GET_ITEM_PROPERTY ('ITEM_NAME', Y_POS);
    -- Also needs to add the Y_POS of the relative other items in the muti-record block
    V_HEIGHT := GET_ITEM_PROPERTY ('BUTTON_NAME', HEIGHT);
    -- Note :- TOP_RECORD  Returns the record number of the topmost visible record in the given block.
    V_Y_POS := V_ITEM_Y_POS + ((V_CURRENT_RECORD - V_TOP_RECORD) * V_HEIGHT);
    -- You will need to add Distance between Items in records if anyThen you can Set the current Y_POS of the button.
    SET_ITEM_PROPERTY ('BUTTON_NAME', Y_POS, V_Y_POS);
    [/code[
    Hope this helps
    Best Regards
    Arif Khadas
    Edited by: Arif Khadas on Feb 24, 2011 4:58 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to enable save and archieve button in smartform output?

    How to enable save and archieve button in smartform output?

    Hi,
    While populating your output parameters, use parameter TDARMOD (Print Archieve Mode: 1,2 3).
    Hope this will hint you how to resolve the issue.
    BR,
    Vinit

  • How to set value for radio button in sap crm survey suite

    Hi ,
    I created a survey in CRM Service, in which I added a question with answer as '10 Selection Button Group ('radio button'). And answer has 11 answer options (which means 11 radio buttions). Now when we test the survey, the value for the radio buttons is appearing like 'id_0050569b03091ee480a29d8ee61e953c'. But i want to set a specific value for each radion button (from 1 to 11). So, how to set value for radio button in sap crm survey suite???.
    Thanks & Regards,
    Seshu

    Hi,
    I found solution myself. Click on Goto -> Editing Mode -> Expert Mode. Now you can set value for radio button.
    Regards,
    Seshu

  • HELP! I need help to understand how to get value on radio buttons!

    hello,
    I realy need the help from anyone that knows how to get value from radio buttons in a JSP.
    I have this :
    <%
    java.util.Vector vLinha = (java.util.Vector) datos.get("ConsNefect");
              java.util.Hashtable ordens;
              java.util.Enumeration eLinha = vLinha.elements();
              String t = "radio";
              String x = "escolha";
              String l = "";
    int i = 0;
              //int esc = 0;
    String fila = "";                         
              boolean bol = true;
    while (eLinha.hasMoreElements())
    ordens = (com.ibm.dse.base.Hashtable) eLinha.nextElement();     
              if (++i%2 == 0)
    fila = "formgriscla";
    else
    fila = "formgrisosc";
    out.println("<tr>");
    out.println("<td class=\"" + fila + "\">");
    out.print("<p class=\"dato2\">");          
              out.print("<a href=" + urls.get("action"));
         out.print("&sequencia=" + (String) ordens.get("sequencia"));                    
         out.print(">");
              out.print((String) ordens.get("descricao"));
         out.print("</a></p></td>");
              out.println("<td class=\"" + fila + "\">");
    out.print("<p class=\"datop\">");          
              out.print((String) ordens.get("datap"));
    out.print("</p>");
    out.println("<td class=\"" + fila + "\">");
    out.print("<p class=\"datop\">");
    out.print((String) ordens.get("erro"));
              out.print("</p>");
              out.println("<td class=\"" + fila + "\">");
              out.print("<p class=\"datop\">");     
              l = (String) ordens.get("sequencia");     
              out.println("<input type=\"" + t + "\" name=\"" + x + "\" value=\"" + l + "\">");          
              out.print("</p></td>");      
              out.println("</tr>");
              //esc++;
    %>
    <!--input type="Hidden" name="escolha" value=<!--%l%>-->
    <!--input type="Hidden" name="escolha" value="<!--%=escolha%>"-->
    </td>
    </tr>
    I don�t know how to take the value... PLEASE HELP ME OUT!
    THANKS TO ALL!,
    Best wishes,
    Alex (portugal)

    You must wrap your contents into a FORM element and, then, using getParameter("escolha"), retrieve your value.

  • How do I give the radio buttons a buttongroup and id dynamically as the datagrid is populated?

    I am using the following component as an item renderer for a
    <mx:DataGridColumn>
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    >
    <mx:HBox horizontalAlign="left" left="10">
    <mx:RadioButton />
    <mx:RadioButton />
    <mx:RadioButton />
    <mx:RadioButton />
    <mx:RadioButton />
    </mx:HBox>
    </mx:Canvas>
    How do I give the radio buttons a buttongroup and id
    dynamically as the datagrid is populated?

    "nikos101" <[email protected]> wrote in
    message
    news:g83gfl$m8o$[email protected]..
    >I am using the following component as an item renderer
    for a
    ><mx:DataGridColumn>
    >
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    >
    > <mx:HBox horizontalAlign="left" left="10">
    > <mx:RadioButton />
    > <mx:RadioButton />
    > <mx:RadioButton />
    > <mx:RadioButton />
    > <mx:RadioButton />
    > </mx:HBox>
    > </mx:Canvas>
    >
    > How do I give the radio buttons a buttongroup and id
    dynamically as the
    > datagrid is populated?
    What is your actual goal?

  • How to enable the print & archive button that appear in the smartform outpu

    How to enable the print & archive button that appear in the smartform output.....

    Hi,
    I agree with the details which has been given above, but still if you want to default option 3 "Print & Archive" in drop down, it is possible.
    All you need to do is to set the value of output_options structure field "TDARMOD" as "3" while passing the parameters to dynamic function module of smartform.
    That will select "Print and Archive" in background and display to user.
    Sumit

  • How to enabling or disabling a layout panel by a radio button

    Hello, I am new in JFS. Can any one help me that i have a layout panel which property set to visible= false initially. And i have a radio button. i would like that when i click the radio button then the layout panel will appear. please help me...............
    regards,
    S. M. Taibur Rahman

    TaiburRahman wrote:
    Hello Dear,
    As your advice i do this but i failed. I don't know what's the problem. As you know i am new in JSF & wed development also. I send you the source code which i compiled here. Please suggestion me the problem.
    Best Regards,
    S. M. Taibur Rahman
    SOURCE CODE:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Document : Page1
    Created on : Feb 18, 2009, 1:22:23 AM
    Author : Taibur
    -->
    <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
    <webuijsf:page id="page1">
    <webuijsf:html id="html1">
    <webuijsf:head id="head1" title="Form1">
    <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
    <SCRIPT LANGUAGE="JavaScript">
    function Disab ()
            document.getElementById("form1:lp1").style.visibility="visible";
            //OR based upon your requirement
            //document.getElementById("form1:lp1").style.visibility="hidden";
    }>
    </SCRIPT>
    </webuijsf:head>
    <webuijsf:body id="body1" style="-rave-layout: grid">
    <webuijsf:form id="form1">
    <webuijsf:radioButton id="rb3" label="2" name="radioButton-group-form1" onClick="Disab()" style="left: 216px; top: 96px; position: absolute"/>Make sure you are passing the right id to your javascript. You can perform a small test on your panel layout by adding onclick="alert(this.id)" to your webuijsf:panelLayout component and use the same id in your javascript function.
    <webuijsf:panelLayout id="lp1" style="border-width: 3px; border-style: dotted; border-color: rgb(102, 204, 255) rgb(102, 204, 255) rgb(102, 204, 255) rgb(102, 204, 255); height: 186px; left: 216px; top: 240px; position: absolute; width: 354px">
    <h:inputText id="textField1" style="left: 123px; top: 51px; position: absolute"/>
    </webuijsf:panelLayout>
    </webuijsf:form>
    </webuijsf:body>
    </webuijsf:html>
    </webuijsf:page>
    </f:view>
    </jsp:root>~SirG

Maybe you are looking for

  • Do I need a training class or a book...

    Slowing me to a crawl... The issue is dealing with and understanding how Flash deals with variables. Right now im setting all to _root so i can see them. However, what I have going on is that I'll define all the variables on a layer that spans over a

  • G5 imac wont connect to gigabit switch at 1000

    Hi, I've got a G5 imac that wont connect to my gigabit switch at 1000. It looks like it connects at that speed for a few seconds then it drops to 100. I have a new Macbook pro that can easily connect at 1000 using that exact same cable. Has anyone he

  • Hyperion Shared Services 11.1.2.x integration

    Hi, I'm trying to locate the docs about integrating OBIEE 11.1.1.5 with Hyperion Shared Services 1.1.2.x. I remember seeing this but can't recall where it is exactly. Can someone point me to the right direction? Thanks. Regards, Gerd

  • HT4623 My iPad doesn't have software update

    When i go into settings my iPad does not have an update software category. What do I do??

  • html:checkbox disabling based on a condition

    does anyone know how to disable the <html:checkbox ?? it should be disabled based on some condition thanks