I have some CheckBoxes which are made of my database table names
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);
}
now lets say I get 10 checkboxes (with different names ofc.). How do I know which of them was checked?
e.g. I check box nr 1.5.7 and click on a button "Print". How do I print them out?
System.out.println("Checked items : " +check);?
Use
CheckboxGroup.add a
CheckboxGroupas follows:and you get the selected value.