English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i use netbeans, and it creates the code for the buttons and text fields automatically, now can i make a method to read all the contents of these fields by a loop
like this (((for example)))

for (i=1;i<10;i++)
str+=(jTextField+i).getText()

is there something near to this?????
cuz i usually write like this
jTextField1.getText();
jTextField2.getText();
jTextField3.getText();
...

2007-03-19 10:17:22 · 1 answers · asked by Medo 3 in Computers & Internet Programming & Design

1 answers

You can't do symbolic references like you're trying to do in Java, but you could make an array that has references to the textfields: JTextField fields[] = {jTextField1, jTextField2, jTextField3}; then iterate through the array. Then if you need to add more textfields you can just change the array initialization and keep the same loop.

2007-03-19 10:23:12 · answer #1 · answered by undercoloteal 3 · 1 0

fedest.com, questions and answers