JAVA -> Combo Boxes


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 :

Who is Participating?
CEHJConnect With a Mentor Commented:
You're mixing your listeners. Should be

ComboTable.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        //  Code in here
RicardoVGomesAuthor Commented:
This is the code I'm using... but when I choose a table in the comboBox on my application... nothing happens...

ComboTable.addActionListener(new selectionListener(){
                  public void valueChanged(ActionEvent event) throws SQLException {
                  String table = (String) ComboTable.getSelectedItem();
                  String query = "SELECT * FROM " + table;

                  theStatement = Data_Extraction.con.createStatement();
                  rs = theStatement.executeQuery(query);
                  ResultSetMetaData rsmd = rs.getMetaData();
              int numColumns = rsmd.getColumnCount();
              for (int i=1; i<numColumns+1; i++) {
                  String columnName = rsmd.getColumnName(i);         
RicardoVGomesAuthor Commented:
Thanks ;)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.