Difference in JComboBox and JSpinner

I'm writing a Java Desktop utility in Java swing and have a minimal GUI part in it, most of work is done on server side i.e. backend. So, I don't want to spend a lot of time on GUI part, learning different controls and widgets. The problem is that Swing has two controls for (to me)same tasks i.e. dropdown menu and they are JComboBox and JSpinner I don't know the difference and I don't want any limitation that would hinder me from completing my task after I've selected one.

I've to use dropdown to display List<String> returned from DataBase and it can have as many as thousands of values. To keep user from scrolling I'll be taking starting alphabet as input or some category limitation will be there so, it may be that I'll be using specific values to be displayed from List<String>. i want my program to be as efficient as it can be and spend least time on front end as there are a lot of operations on backend.

Any Help will be highly appreciated


I've to use dropdown to display List returned from DataBase and it can have as many as thousands of values.

  • all above mentioned JComponents are based on premature array, maybe need to convert java.util.List to String[] or Vector (depends of your code logics)

  • none of GUI are designated to helt the thousands of values, have look at Paginations for Databases engine

  • above mentioned AutoComplete JComboBox / JTextField works without any issue up-to 2k rows on todays PCs

  • for searching or selections from largiest arrays you have look at Stepped JComboBox (about two or more JComboBoxes)

    1.st for reduced selection from [0-9, A-Z]

    2.nd for searching in records started with A (for example)

  • redirect Database events to the background tasks and to use SwingWorker or Runnable#Thread

The key difference lies in the model: a SpinnerModel implementation creates a sequence of values, while a ComboBoxModel does not. If objects in a SpinnerModel do not have a suitable natural order, you'll need to impose one.

As practical matter, "thousands of values" will benefit from an auxiliary approach, as suggested in @mKorbel's answer.

Need Your Help

Formula to reference data from a PivotTable

excel excel-formula excel-2010 pivot-table worksheet-function

I am having some difficulty writing a specific Excel formula. I have a summary sheet that pulls data from various other sheets extracted from a database. One of these is a PivotTable whereby using ...

Angular 2.0 migration path

javascript angularjs angular2

I am preparing a talk about "Be ready for Angular 2.0 today" and I intend to talk about application structure changes needed in order to make the migration path easier (I know, Angular 2.0 is not r...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.