literal string expansion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerre Snow

    #1

    literal string expansion

    I have 150 checkboxes named jCB001...jCB150 .
    How would I loop through them in a for/next loop performing actions on
    them. If I held their names in an array, how would I make use of that
    String in the array to reference the checkbox object? Is there a way
    to do this?
  • kn

    #2
    Re: literal string expansion

    >I have 150 checkboxes named jCB001...jCB150 .
    How would I loop through them in a for/next loop performing actions on
    them. If I held their names in an array, how would I make use of that
    String in the array to reference the checkbox object? Is there a way
    to do this?
    That's not a proper way to do it. You should create a combobox array and
    then iterate through it. Alternatively, you can put your comboboxes onto a
    JPanel and then use
    JPanel.getCompo nents() to get your comboboxes as an array.


    Comment

    • Jerre Snow

      #3
      Re: literal string expansion

      On Tue, 19 Dec 2006 10:32:02 +0100, "kn" <necuspam@necus pam.hrwrote:
      >>I have 150 checkboxes named jCB001...jCB150 .
      >How would I loop through them in a for/next loop performing actions on
      >them. If I held their names in an array, how would I make use of that
      >String in the array to reference the checkbox object? Is there a way
      >to do this?
      >
      >That's not a proper way to do it. You should create a combobox array and
      >then iterate through it. Alternatively, you can put your comboboxes onto a
      >JPanel and then use
      >JPanel.getComp onents() to get your comboboxes as an array.
      >
      It hadn't occurred to me to look for methods in the underlying jpanel.
      JPanel.getCompo nents() solved the problem.

      Component[] c = jPanel.getCompo nents();
      JCheckBox jc = (JCheckBox) c[i];

      Comment

      Working...