【发布时间】:2018-09-22 23:23:16
【问题描述】:
我试图在这里不使用大量的 IF 语句。 我有 26 个不同的盒子,分别命名为 txtA、txtB、txtC 等。
我要创建的是一种可以使用变量“box”的方法来给出
String result = txt(box).getText();
方框将替换任何字母。
谢谢,这是我的代码
public static String getTextBoxInput(char box) {
String result = txtA.getText();
return result;
}
【问题讨论】:
-
你想要一个数组。
-
或
ArrayList<JTextField>或 Map,例如 HashMap。