5 Replies Latest reply on May 29, 2012 6:43 AM by Nitin Khare

    help required on JComboBox

      Hi I have 500 customers in the database. I have to display the customer names in a JComboBox so that user will select the customer name. here i have a problem. pulling 500 customers at a time and displaying them in combobox will take time. the customers may even grow up to thousands. so i don't want to display all the customer names at once in the JComboBox. First i want to display 50 names and when customer pulls the scrollbar to the end of the JComboBox popup then i want to add another 50. How can i do this?

      kindly help me in this regard. Thanks in advance.
        • 1. Re: help required on JComboBox
          Don't use a JComboBox. Use a JTable with a customized model instead.

          UPDATE: you can supply your own model to a JComboBox too.


          Edited by: marcos_aps on 25/05/2012 11:26
          • 2. Re: help required on JComboBox
            Hi can u explain little bit more on how i can use jtable for my requirement. I am not able to figure out how i can use jtable for my requirement.
            • 3. Re: help required on JComboBox
              Well, you will have to configure your table to look like a JList, so no header and no grid lines. Of course it won't have a button to select items like a combo box, but the data will be fetched lazily as you want if you provide a custom table model. Regarding custom table models, you can look here:


              • 4. Re: help required on JComboBox
                Ay suggestions? kindly help me in this.
                • 5. Re: help required on JComboBox
                  Nitin Khare
                  I do not think users would normally prefer to scroll through thousands or more items in a combo box to pick their choice. You may want to redesign your GUI somewhat like splitting the data into categories and use two combos, one for categories and one for the data and populate the data one based on the value selected on the category one. In case splitting like this is not possible then you may consider to apply some filtering in your JComboBox/JTable so that users can select their choice as they type. I guess this may be of some help to you