• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Filling ComboBox with Loads of Data

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Brian
 
reply
    Bookmark Topic Watch Topic
  • New Topic