I have some CheckBox that are made from the names of my database table
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 I will say that I get 10 flags (with different names c.), how do I know which one was checked?
eg. I check the box nr 1.5.7 and click the "Print" button, how to print them?
System.out.println("Checked items : " +check); ?
Kiesa source share