How can I add checkboxes, depending on the number of columns that a table has?.
I have a ComboBox where I can choose one table from my database, and the program will make a select depending on what check box you checked. I know how to get the number of columns, but I dont know how to make as many check boxes as that number. The number is different depending on the item selected on the comboBox (the table) The checkBox Using JFrame:
JComboBox<String> tabla = new JComboBox();
tabla.setBounds(10, 650, 200, 25);
tabla.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (tabla.countComponents() > 0) {
item_sel = tabla.getSelectedItem().toString();
try {
ResultSet rs1 = stmt.executeQuery("select * from "+item_sel);
ResultSetMetaData rsmd = (ResultSetMetaData) rs1.getMetaData();
int columnsNumber = rsmd.getColumnCount();
for(int i = 0; i<= columnsNumber-1; i++) {
//here I add comboBox
}
} catch (SQLException e2) {
// TODO Auto-generated catch block
System.out.println(e2);
}
}
}
});
Also: How do I set the bounds different in each comboBox?