RicardoVGomes
asked on
JAVA -> Combo Boxes
Hello,
I have 2 combo boxes and want one do something when a component is chosen on the other one.
ComboBox A -> Tables from a database
ComboBox B -> Columns from Table in ComboBox A
I can get the tables in CombBox A.... and the columns from a table....
I need the structure of how to start this and where do I put the code..... Think it will be something like :
ComboTable.addActionListen er........ .......... ..
I have 2 combo boxes and want one do something when a component is chosen on the other one.
ComboBox A -> Tables from a database
ComboBox B -> Columns from Table in ComboBox A
I can get the tables in CombBox A.... and the columns from a table....
I need the structure of how to start this and where do I put the code..... Think it will be something like :
ComboTable.addActionListen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks ;)
:-)
ASKER
ComboTable.addActionListen
public void valueChanged(ActionEvent event) throws SQLException {
String table = (String) ComboTable.getSelectedItem
String query = "SELECT * FROM " + table;
theStatement = Data_Extraction.con.create
rs = theStatement.executeQuery(
ResultSetMetaData rsmd = rs.getMetaData();
int numColumns = rsmd.getColumnCount();
for (int i=1; i<numColumns+1; i++) {
String columnName = rsmd.getColumnName(i);
ComboColumn.addItem(column
}
}
});