Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-15-2009, 02:56 PM
Member
 
Join Date: Dec 2008
Location: Aveiro,Portugal
Posts: 2
Rep Power: 0
Glouze is on a distinguished road
Default List in Combobox database values
Hi! Im trying to create a combobox using stripes, and i need to list in that combobox some fields that i have in my database. Can anyone give me some help?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-16-2009, 06:26 PM
Steve11235's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 972
Rep Power: 2
Steve11235 is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to set() values of in list of arraylist alvations New To Java 15 10-13-2008 10:35 PM
[SOLVED] Creating List of Values Using ClipBoard Object Judoon_Platoon Java Applets 2 05-21-2008 09:07 AM
getting values from database in dropdown aa74 JavaServer Pages (JSP) and JSTL 1 04-21-2008 11:00 PM
ComboBox with database options Goldy Advanced Java 0 12-01-2007 10:43 PM
Getting values of an Option List mutuah Advanced Java 0 08-07-2007 04:42 AM


All times are GMT +2. The time now is 12:58 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org