【发布时间】:2011-11-22 19:23:47
【问题描述】:
我有一些由我的数据库表名组成的复选框
if(event.getSource()==connect){
CheckBox check;
Connection connection = null;
try {
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/db";
String username = "username";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
// Gets the metadata of the database
DatabaseMetaData dbmd = connection.getMetaData();
String[] types = {"TABLE"};
ResultSet rs = dbmd.getTables(null, null, "%", types);
while (rs.next()) {
String tableCatalog = rs.getString(1);
String tableSchema = rs.getString(2);
String tableName = rs.getString(3);
check = new CheckBox(tableName);
Tables.addComponent(check);
}
} catch (SQLException e) {
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Tables.addComponent(generate);
}
现在假设我有 10 个复选框(具有不同的名称)。我怎么知道哪些被检查了?
例如我选中 nr 1.5.7 并单击“打印”按钮。如何打印出来?
System.out.println("Checked items : " +check);?
【问题讨论】: