更新时间:2022-06-18 05:30:14
不清楚 FIELDS
是你的 JTextField
数组还是常量.如果是组件数组本身,在迭代时考虑使用.length
数组字段.这减少了代码维护:
It's unclear is FIELDS
is your JTextField
aray or a constant. If it is the component array itself, consider using the .length
array field when iterating. This reduces code maintenance:
JTextField[] fields = new JTextField[SIZE];
for (int i = 0; i < fields.length; i++) {
fields[i] = new JTextField("Field " + i);
fields[i].addActionListener(myActionListener);
c.add(fields[i]);
}
注意大写变量用于 Java 命名约定下的常量.
Note uppercase variables are used for constants under Java naming conventions.