A question
<[email protected]> Mon, 17 Sep 2012 16:06:21 +0300 (EEST)
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I am trying to use BeanShell for something that I don't know if it is ever possible...Plese tell me is there a way to do it or stop wasting time on this.
I have these visual elements:
Label a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
I have an array of words:
String[] words = result.split(" ");
This code works fine:
a1.setText(words[0]);
a2.setText(words[1]);
a3.setText(words[2]);
a4.setText(words[3]);
a5.setText(words[4]);
a6.setText(words[5]);
a7.setText(words[6]);
a8.setText(words[7]);
a9.setText(words[8]);
a10.setText(words[9]);
But what if I have not 10 but 100 elements...So I try to use this:
for (int i=0;i<=maxwords;i++) {
Interpreter interpreter = new Interpreter();
try {
interpreter.set("tmp",words[i]);
interpreter.set("a","a"+String.valueOf(i));
interpreter.eval("a.setText(tmp)");
} catch (EvalError e2) {
e2.printStackTrace();
}
}
The problem is with this command:
interpreter.set("a","a"+String.valueOf(i));
If I use this:
interpreter.set("a",a1);
Everything is OK but what is the point to call all elements one by one again?
Best wishes
Georgi Bonchev
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/