English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am making a form where I want the options for the combo box to come from data in a mySQL database. I am using netbeans to make the form and the combo. Any advice?

2007-01-22 10:08:21 · 1 answers · asked by Ryan300x 2 in Computers & Internet Programming & Design

1 answers

First, go learn JDBC so you can retrieve the result set with your data.
http://java.sun.com/docs/books/tutorial/jdbc/

Once you have your data, put it in a ComboBoxModel (the DefaultComboBoxModel class will do). Then set that as the model for your JComboBox, either at construction time or later using setModel().

Warning! The above approach assumes a small data set. If the data set from the database could be rather large, use a scrollable result set and build a custom combo box model that uses the scrollable result set and only caches a small set of the data.

2007-01-23 12:30:18 · answer #1 · answered by vincentgl 5 · 0 0

fedest.com, questions and answers