Hi all,
I am having a little problem with clearing JTextFields from my GUI application. The problem is I created a load of JTextFields in an array (shown below)
int[] txtfieldwidths = { 20, 20, 20, 20 } for ( int i = 0; i < txtLbls.length; i++ ) { gridbagcons.gridwidth = GridBagConstraints.RELATIVE ; labelNames = new JLabel( txtLbls[i] ); formPanel.add( labelNames, gridbagcons ); gridbagcons.gridwidth = GridBagConstraints.REMAINDER ; labelTxtFields = new JTextField( txtfieldwidths[i] ); formPanel.add( labelTxtFields, gbc ); }
I also have a button with an actionListener attached to it which is supposed to clear the JTextFields (shown below)
if ( e.getSource( ) == btnClear ) { labelTxtFields.setText(""); }
The problem is when I go and click on the clear button, only the last JTextField is being erased and none of the others above it.
Is there a way I can get all the JTextFields to clear?
Hope you can help me!