ResultSet rs2 =db.getResultSet("select e_name from employee");
try{
final Button[] bt=new Button[count];
final String[] a=new String[count];
while (rs2.next()) {
int i=0;
a[i]=rs2.getString(1);
bt[i]=new Button(c,SWT.CHECK);
bt[i].setText(a[i]);
bt[i].setBackground(new Color(Display.getCurrent(), 255, 255, 255));
c.setSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
//System.out.println(bt[i].getText());
i++;
}
System.out.println(bt[1].getText()); }catch (SQLException e2){
e2.printStackTrace();
}
count是定义的全局变量,返回employee表的行数
本意是从表中取出name,付给多选按钮的text
注释的语句可以返回所有的name
但红色那句就不行了,错误信息是没值——如果是返回bt[0].getText则可以请教是什么原因?如果我想在while循环外打印这些bt[i].getText该如何作呢?