Results 1 to 2 of 2
Thread: List in Combobox database values
- 01-15-2009, 01:56 PM #1Member
- Join Date
- Dec 2008
- Rep Power
- 01-16-2009, 05:26 PM #2
First, you need to use JDBC to read the fields from your database. Do this only once, unless the fields in the database are constantly changing. I assume you are creating a Swing UI or something similar, so that's normally pretty easy. For Web apps, that have to generate the combo box over and over, create a separate class to read the fields and store them in a list. Use a static method to retrieve the list. This way, many classes on many threads can use the list.
As far as striping the entries, in Swing, that's beyond my abilities. The problem is that JComboBox accepts a list of objects and uses something like toString() to get the values it displays. When you ask the component what is selected, it returns the object, which is very helpful. However, the implementation does not appear to provide a means of controlling how the lines are produced. Look at ComboBoxUI if you like.
- By alvations in forum New To JavaReplies: 15Last Post: 10-13-2008, 09:35 PM
- By Judoon_Platoon in forum Java AppletsReplies: 2Last Post: 05-21-2008, 08:07 AM
- By aa74 in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-21-2008, 10:00 PM
- By Goldy in forum Advanced JavaReplies: 0Last Post: 12-01-2007, 09:43 PM
- By mutuah in forum Advanced JavaReplies: 0Last Post: 08-07-2007, 03:42 AM