How do I check if checkboxe(s) selected, please

Hello,
I am creating Checkboxes on runtime which I am able to do so.
I have been trying to find out if one or more are selected. Please
see my code:
Thanks.

USe the "selected" property of the checkbox to determine if
it is selected or not.

Similar Messages

  • How to Figure out what checkboxes are selected upon a button click...

    If I have a panel with some JCheckBoxes and a JButton, how can I figure out what checkboxes are selected upon the button click? If I add an actionlistener to the button, inside actionPerformed, how would I know what checkboxes are selected? One caveat is that the name and number of these checkboxes are dymanically chaing based on a configuration file so I do not know what the names of these check boxes are.
    Any help/code sample would be appreciated.

    Here's one of several different ways to do it. It attaches an ItemListener to each checkBox. When the checkBox is clicked, it is either added or removed from a List of selected items. Clicking the button will show you the selected items.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class CheckBoxTest extends JFrame
      JCheckBox chkChoice1 = new JCheckBox("English");
      JCheckBox chkChoice2 = new JCheckBox("French");
      JCheckBox chkChoice3 = new JCheckBox("German");
      JCheckBox chkChoice4 = new JCheckBox("Italian");
      JTextArea txaDisplay = new JTextArea(5, 20);
      JButton btnShow = new JButton("Show Selected Items");
      ArrayList <JCheckBox>choices = new ArrayList<JCheckBox>();
      public CheckBoxTest()
        super("");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        chkChoice1.addItemListener(new CheckBoxListener(chkChoice1));
        chkChoice2.addItemListener(new CheckBoxListener(chkChoice2));
        chkChoice3.addItemListener(new CheckBoxListener(chkChoice3));
        chkChoice4.addItemListener(new CheckBoxListener(chkChoice4));
        btnShow.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent event)
            txaDisplay.setText("");
            for (JCheckBox jcb : choices)
              txaDisplay.append(jcb.getText() + "\n");
        JPanel buttonPanel = new JPanel(new FlowLayout());
        buttonPanel.add(chkChoice1);
        buttonPanel.add(chkChoice2);
        buttonPanel.add(chkChoice3);
        buttonPanel.add(chkChoice4);
        JScrollPane scroll = new JScrollPane(txaDisplay);
        scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        JPanel dataPanel = new JPanel();
        dataPanel.add(btnShow);
        dataPanel.add(scroll);
        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        c.add(buttonPanel, BorderLayout.NORTH);
        c.add(dataPanel, BorderLayout.CENTER);
        pack();
      public static void main( String[] args )
        CheckBoxTest frame = new CheckBoxTest();
        frame.setVisible(true);
      class CheckBoxListener implements ItemListener
        JCheckBox checkBox;
        public CheckBoxListener(JCheckBox checkBox)
          this.checkBox = checkBox;
        public void itemStateChanged(ItemEvent event)
          if (checkBox.isSelected())
            choices.add(checkBox);
          else
            choices.remove(checkBox);
    }Or, you could just maintain all the checkboxes in a Collection ahead of time. When the Show button is selected, simple query isSelected() on each item.
    Again, there are several different ways.

  • How to create check boxes dynamically in selection screen

    Hi Experts,
    I have a requirement of creating dynamic check boxes based on the number of records that are retrieved from a database table.
    Can you please suggest me how to achieve it.
    Regards
    RP.

    Hey RP,
    Try this way.
    REPORT ztest_program .
    DATA: it_data TYPE TABLE OF t001.
    DATA:check    TYPE char3.
    DATA:sy_index TYPE char2.
    DEFINE checkbox.
      parameters:&1 as checkbox.
    END-OF-DEFINITION.
    CHECKbox:c01,c02,c03,c04,c05,c06,c07,c08,c09,c10,
             c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,
             c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,
             c31,c32,c33,c34,c35,c36,c37,c38,c39,c40.
    AT SELECTION-SCREEN OUTPUT.
      DESCRIBE TABLE it_data LINES sy-tfill.
      sy-tfill = 39. "This will be changed based on the itab records. I just hardcoded the value
      sy_index = 1.
      LOOP AT SCREEN.
        CONCATENATE 'C' sy_index INTO check.
        IF screen-name = check.
          IF sy_index GT sy-tfill.
            screen-active = '0'.
            MODIFY SCREEN.
            sy_index = sy_index + 1.
            CONTINUE.
          ENDIF.
          sy_index = sy_index + 1.
        ENDIF.
      ENDLOOP.
    Thanks
    Venkat.O

  • How can I check which JRadioButton is selected in whichTabbedPane?

    Hello,
    I have several TabbedPanes with a mass of JRadioButtons in one ButtonGroup. Now I search an easy way how I can find out which RadioButton is selected in which TabbedPane. With "getParent()" I can get a lot but not e.g. the name of the TabbedPane.
    Thanks for your help
    Arthur

    I'm not sure that it's what you want but you can do something like this:
    for the checked radio button to getParent and then
    to try
    int i = tabbedPane.indexOfComponent( checkedRadioButton );
    and if you know the indexing of your radionbuttons you can find, It's for sure not nice
    solution but it is the first what come to me ;-).
    Best regards.

  • How do i "Check" a Checkbox?

    Hi!
    I´ve got a problem. I check if a specific field is empty i want to set an Checkbox.
    But i cant find the rigt expression! does somebody have an example for that kind of expression?

    Hi !
    Try something like this in the default value of your checkbox and check the "post default value box" :
    IIf(YOUR FIELD IS NULL OR YOUR FIELD = '', "Y", "N")
    Hope this will help, feel free to ask more !
    Max

  • How can I check a checkbox status?

    I am writing an invoice which involve parts and labor for an auto shop.  A check box precedes each line.  If the checkbox is checked, then the line is for a part, which I will use to add parts and labor separately for tax and information purposes.
    Question:  Using Acrobat Professional 8, what Java code would check whether a checkbox named CB1 is checked or not?.
    Papaturro

    Post your question in the forum for Acrobat Scripting.

  • Check multiple checkboxes for selected

    I want to see if I can reduce my code more. I have five check
    boxes on the screen and when they are all checked, I want to call a
    function. I don't want to have a long if statement because I will
    re-use this and would prefer to have as streamlined as possible.
    Here is my code now. Thanks.
    var checkboxListener:Object = new Object();
    checkboxListener.click = function(evt_obj:Object) {
    for (cb=1; cb<6; cb++) {
    if (_root["c"+cb+"_ch"].selected) {
    nextItem()
    for (cb=1; cb<7; cb++) {
    this["c"+cb+"_ch"].addEventListener("click",checkboxListener);
    function nextItem() {
    if (c1_ch.selected && c2_ch.selected &&
    c3_ch.selected && c4_ch.selected && c5_ch.selected
    && c6_ch.selected) {
    trace("do something") }
    }

    var checkboxListener:Object = new Object();
    var cbTotal:Number = 5;
    checkboxListener.click = function(evt_obj:Object) {
    var numChecked:Number = 0;
    for (cb=1; cb<=cbTotal; cb++) {
    if (_root["c"+cb+"_ch"].selected) {
    numChecked++;
    if(numChecked==cbTotal){
    trace("do something");
    }

  • How do i check if i have WEP please???

    hey guys!!
    i got a linksys wireless access point at home and because my imac G5 is pretty new i was impressed that it was so easy to set up to my wireless network.
    i am sure i set up my WEP with the imac (i have my xbox 360, nintendo DS, PSP & PC on same wireless network using the WEP key) but where do i check to make sure please?
    thanks
    BM

    Hi Monk,
    Open up your System Preferences, and select the Network pane.
    In my AirPort settings, in the Preferred networks area, I can see the network I am connected to. If I select it, and Edit it, I get a dialog box that shows the Network Name, Wireless Security, and Password. Below that is a checkbox for Show Password, and if I turn it on, it shows me the actual WEP password I am using to connect.
    Now... under AirPort Options (at the bottom of the main AirPort screen), I have the Automatically add new networks to the preferred networks list option checked, so my network was automatically added to the list when I connected. I'm not sure if this is on by default, so please take a look and let me know if you find what you're looking for.

  • How can i check the segment in idoc.

    hi gurus,
       how can i check the segment in idoc.please help me as

    Hi Rohit,
    In WE02/05 U can view the IDocs.
    Since u r having the IDoc with u, Double click the Idoc no. and it will take you to screen where it will show you all the segments of IDoc. Here you can check which segment is giving error.
    Go to  WE60/63 which shows the detailed documentation in the MySAP environments if u have been using the old 4.6c systems. In 6.10 since the documentation is not available ,modify your personal settings to show the documentation by default; In 6.10 in transactions WE60 and WE63, documentation is no longer generated by default for the segment fields when the documentation is generated. To activate the generation of the documentation from the corresponding data elements, proceed as follows: WE60/WE63. > Goto > User settings. Here you must set the indicator for 'Display of the documentation' under 'Display attributes for IDOC types' and then save the change. Now the documentation is also displayed for the segment fields when WE60/WE63 is executed.
    **Reward points if u find this useful.
    Thanks & Regards,
    gyanaraj

  • How to count number of checkboxes selected from a table in sapui5

    Hi
    I have a table in which one of the column is checkbox.
    Now user can check 'n' number of checkboxes in the same column.
    So now i need to count the number of checkboxes selected in that column.
    how to do that..??
    Please help me on this.
    Thanks
    Sathish

    Hi Sathish,
    If you are using table mean surely you are binding the table to some model like JSON model. You can bind the checked value of the column with the checkbox in the template. So while checking you can directly check the property by taking the reference from the model. Navigate through all the objects in the model and check  the property you wanted.
    This is the logic I have used to get the checked property form the table column. My table id is "tableId" and it is being binded with "/tableModelData" of json model.
      var myModel = sap.ui.getCore().getElementById("tableId").getModel().getProperty("/tableModelData");
      for(var i= 0 ; i< myModel.length ; i++)
      var singleObject = myModel [i];
      if(singleObject.checked ==  true){
    your logic.

  • How to get a check box on the selection screen

    Hi all
    can any body tell me how to get a check box on the selection screen

    parameter: pa_check   as checkbox.
    To define the input field of a parameter as a checkbox, you use the following syntax:
    PARAMETERS <p> ...... AS CHECKBOX ......
    Parameter <p> is created with type C and length 1. In this case, you may not use the additions TYPE and LIKE. Valid values for <p> are ' ' and 'X'. These values are assigned to the parameter when the user clicks the checkbox on the selection screen.
    If you use the TYPE addition to refer to a data type in the ABAP Dictionary of type CHAR and length 1 for which 'X' and ' ' are defined as valid values in the domain, the parameter automatically appears as a checkbox on the selection screen.
    REPORT DEMO.
    PARAMETERS: A AS CHECKBOX,
    B AS CHECKBOX DEFAULT 'X'.

  • How to check a checkbox

    Hello,
    I am using the interapplication communication API classes from my c# program. I read an  previously generated xml and write the data to the live cylce pdf form
    I use the below classes and use the IField.value( myField.Value = xmlcolValue;) to write to the form. It works fine for all the text boxes, But is not writting/selecteing/checking  the checkboxes.
    I have tried using the IFeild.setExportValues(..) but it gives me an error "Security setting prevent me from doing that".Could you please let me know how to solve this issue?
    CAcroAVDoc  
    Thank you
    IAFormApp  IFields   IField

    Hello,
    Still searching for the same issue. Does anyone have a solution/fix for this?
    Thanks

  • How to check whether checkbox is checked or not and to get label if checked

    Hi,
    I've used checkboxgroup, and i'm populating it dynamically using attribute node & attribute value.. like this
    IPrivateTestView.IWelcomNode wNode =wdContext.nodeWelcom();
         IPrivateTestView.IWelcomElement wEl,wE2,wE3;
         wEl=wNode.createWelcomElement();
         wNode.addElement(wEl);
         wEl.setWelValue("Welcome Boards");
         wE2=wNode.createWelcomElement();
         wNode.addElement(wE2);
         wE2.setWelValue("Traditional Welcome");
         wE3=wNode.createWelcomElement();
         wNode.addElement(wE3);
         wE3.setWelValue("Photograph");
    now i want to check whether checkbox is checked and how many checkbox has been checked and then i want that label values of checked boxes.. so pls help me out. if possible give me some sample coding...

    CheckBoxGroup.texts -> Welcom.WelValue
    In controller method (e.g. action handler):
    IWelcomNode node = wdContext.nodeWelcom();
    for (int i = 0; i < node.size(); ++i)
      IWelcomElement e = node.getWelcomElementAt(i);
      if (node.isMultiSelected(i))
        String text = e.getWelValue();
        /* checkbox #i is selected and variable "text" contains the text */
    Armin

  • How to read whether dynamic checkboxes are checked or not

    Hi experts ,
              I have created number of checkboxes dynamically. I want to read whether they are checked or not. If they are checked I will do some operations and if not checked some different operations are to be done. Please tell me how to read that checkbox is checked or not.
    Please help.
    Thanks & Regards,
    Pratibha

    Hi pratibhas ,
    While creating the checkbox dynamically, you can bind that checkbox with some context attribute of type WDY_BOOLEAN.
    Now when you need to see whether a perticular checkbox is selected or not, check it's attributes value whether it is 'X' or ' ' .
    Regards,
    Vikrant

  • Can I cause checking a box to add 1 to a calculated form field?  I have a field that sums the numbers entered in several previous fields and need to be able to add "1" if a checkbox is selected as well.

    Can I cause checking a box to add 1 to a calculated form field?  I have a field that sums the numbers entered in several previous fields and need to be able to add "1" if a checkbox is selected as well.

    I think it has something to do with the way the value of the check box is exported, but I'm not sure.  With nothing being exported to Data5, Data6 displays the sum of Data1-4 rounded down to the nearest whole number and updates automatically as Data1-4 are updated.
    Right now, assuming Data1-4 are 0, where data 5 is the output of the second example and any box is checked,  "1" is displayed in data5 but nothing is added to data 6. Selecting any other check box or deselecting that check box will cause data6 to add 1 even if data5 displays "0".  By way of example:
    Selecting Check box 16 results in Data5 displays 1 and Data6 displays zero.
    Then, if any or all of Checkbox17-20 are selected, Data5 displays 1 and Data6 displays 1.
    Then, if any or all of Checkbox17-20 are deselected, Data5 Displays 1 and Data6 displays1.
    Then, if Checkbox16 is deselected, Data5 displays 0 and Data6 displays 1.

Maybe you are looking for