JTextFields process

Please, help!

I have a problem and I can't resolve it. Maybe you can help me. I hope so.

I have 18 JTextFields and they have nearly alike name(txtA1, txtA2, txtA3, txtB1, txtB2...). So, I

want to do method to process them only have a part of name.

For example:

public String doJTextFields(String s){

...

ccc = (txt + s + 1).getText()

...

}

How to force compiler to understand that"(txt + s + 1)" means "txtA1" or "txtB1".

[585 byte] By [Igoreka] at [2007-10-1 4:24:20]
# 1
If you want to do this within a Java program, you can use java's Regular Expression capabilities, and use String.matches(regex) to match multiple names.The compiler doesn't have anything to do with this, the Java code you use is what matters.
ChuckBinga at 2007-7-9 4:54:23 > top of Java-index,Administration Tools,Sun Connection...
# 2
Please give a short example. I don't understand how to do this
Igoreka at 2007-7-9 4:54:23 > top of Java-index,Administration Tools,Sun Connection...
# 3

One way to do this is to use a HashMap.JTextField jtf1 = new JTextField("1");

JTextField jtf2 = new JTextField("2");

JTextField jtf3 = new JTextField("3");

HashMap map = new HashMap();

String s = "jtf";

map.put(s+"1",jtf1);

map.put(s+"2",jtf2);

map.put(s+"3",jtf3);

JTextField get1 = (JTextField)map.get(s+"1");

JTextField get2 = (JTextField)map.get(s+"2");

JTextField get3 = (JTextField)map.get(s+"3");

System.out.println(get1.getText());

System.out.println(get2.getText());

System.out.println(get3.getText());

atmguya at 2007-7-9 4:54:23 > top of Java-index,Administration Tools,Sun Connection...
# 4
It might be that changing your design provides a better solution. You didn't post enough info to tell.
atmguya at 2007-7-9 4:54:23 > top of Java-index,Administration Tools,Sun Connection...