I have I have several text fields (integer, double, and others) and I want them to call This is my code: What's the problem? Not It is a matter of course that you are adding an element on each iteration to IndexOutOfBoundsException , and I do not know why.
ArrayList < String & gt; But the information must be used accordingly. Tag Content
jLabelAL = new arreelist & lt; & Gt; (); JTextFieldAL = New ArrayList & lt; & Gt; (); For (int i = 0; i & lt; size; i ++) {jlabel.ed. (new jlabel ("++ tagassamic.ast (i))"; switch (tag contentant.lit (i) .toString ( Case "Double": Case "Float": jTextFieldAL.add (JTextField) new tool. DoubleTextField (Simulation) ); Break;; "jtextFieldAL.add (JTextField) new JTextField (); breakdown;} JTextFieldAL.get (i) .addKeyListener (keyEvent); // IndexOutOfBoundsException p1.add (jLabelAL.get) in this line (I)); p1.add (jTextFieldAL.get (i));}
jTextFieldAL , since there is no default case in the switch if you have not added a code to
jTextFieldAL , Then every one of the present is to run again, and when you have
jTextFieldD.get (i) , the last element (if any) has an index
i < / Code>. In practice, this means that you will get the first
IndexOutOfBoundsException at the frequency of the code in which you are unable to add an element to
jTextFieldAL .
No comments:
Post a Comment