• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filling ComboBox with Loads of Data  RSS feed

 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have a JCombobox which must be filled in with a large number of Data(May be millions of elements).

So It will take a lot of time to load the combobox.The data to load the combobox is got from the server.

So I have decided to implement the "Value List Handler" pattern which gives always a sublist of the whole list of data.

Following is a link of the "value list handler" pattern link.

http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html.

It has methods for getting a sublist from the whole list.


So my real problem or what I need is as follows:


The JComboBox on loading will be initially populated ,with the values it gets from the "valueListIterator"(a subList).But the scrollbar should look in a way that the combobox is filled with the whole list.

When the user scrolls down or moves up the other sublists are got from the server(Using the Iterator) & the combobox must have to be filled in with this sublist.

So In short the combobox gets its values in pieces while scrolling up & down the list either using the scroll bar or using the up,down arrow keys.

For the end user, the behaviour of the combobox is as if the whole list of data is loaded into the comboBox.

Another thing is,When should be the new sublists loaded into the comboBox ,I mean which is the scrollBar level, when the newsublists should be loaded..

How Can I achieve the above behaviour in the JComboBox.Any help or tips in this direction is appreciated.


Thanks
K
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I havent tried it yet, but you can try overriding the getSize() in the combo box model. If I am not mistaken, this should determine the scroll behaviour.
 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maneesh.Will try that

Do you have any idea which listener should be added to the combobox when the user moves the scroll bar up & down...
 
Brian Cole
Author
Ranch Hand
Posts: 949
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Sanker:
Do you have any idea which listener should be added to the combobox when the user moves the scroll bar up & down...


The "normal" way this is handled is not to use listeners. The combobox will call its model's getElementAt(int index) method it needs data, so all your custom implementation of ComboBoxModel needs to do is react to the index parameters as they come.

I guess you might want to look into making some kind of tweak so that quick user scrolling doesn't force retrieval of all intermediate values.

(btw, if there are really millions of elements, I'm not sure JComboBox is the way to go. I might look into some kind of auto-completion field or something treelike.)

[edit: left out a verb]
[ September 04, 2007: Message edited by: Brian Cole ]
 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Brian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!