Results 1 to 2 of 2
  1. #1
    Glouze is offline Member
    Join Date
    Dec 2008
    Location
    Aveiro,Portugal
    Posts
    2
    Rep Power
    0

    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?

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    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.

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •