2 Replies Latest reply on Dec 24, 2012 8:45 AM by 980759


      Hi folks,

      I am new to Java and fairly new to programming in general. I have spent a couple of years in MS Access/VB.

      In my quest to broaden my skill set I have started to play with Java. Honestly it seems to require a lot of code and classes to do the littlest thing.

      My issue is this I have a mysql db with a customer table. I want by combobox to store the id and customer name but only display the customer name in the combobox.

      When the user selects a customer I want the id to query the jtable and display the customer info.

      I need to reference this id from the combobox to correctly populate the table.

      So my table will look like this
      id customername address city
      1 customer1 123 this st atown
      3 customer2 5 that st btown
      4 customer 3 989 overhere st ctown
      2 customer 4 9999 overthere st dtown
      6 customer 5 234 thisstreet st etown

      So when the user selects customer2 from the combobox it will in turn say customer2's id is 3.
      3 will then be used to query the customer information and display this in the table.

      I hope iam explaining this correctly... this was very common in ms access but all i had todo was hide the column with the id so it only displayed the customer name. When a new customer was selected it would take the hidden id column value to populate a table. It was extremely easy.
        • 1. Re: Jcombobox!!
          861399 wrote:
          this was very common in ms access
          That's because it was designed for simple things like this. There are plenty of applications for Java that would be impossible (or at least very unwise) for Access/VB combo.

          Anyhow, I would start with the tutorial at http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html and see if that'll help.

          I'm assuming you are having trouble with the combobox and not the mysql part?
          • 2. Re: Jcombobox!!
            you need to use data model to support what you expecting
            please go through the below link