Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

column fields values questions

 
Kruger Scheitz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the JCombobox fields values, i would like to know how does everyone normally implement them? do they hardcode them or get the field values from the db ?? pls help
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personnally, I read those values from the database ...
This is more generic.
But of course, you could also hardcode them.

Stephane
 
Kruger Scheitz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if u get the values from the db, i guess u need to write some algorithm method to elimate the duplication of values when the combobox retrieves the them from db...am i right?
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes indeed.
But as I am using a HashSet as temporary structure while reading the database, this takes care of eliminating duplicates for me.
And I just ahve to fill the combo with the contents of the HashSet.
Stephane
 
Kruger Scheitz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh that's cool
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ArrayList serves about the same purpose as HashSet, and sorting an ArrayList is fairly painless using java.util.Collections (hint, if you have a box for selecting flight days, you shouldn't use an alphabetic sort )
I also get my column names from the database. On the other hand, Michael Morris said he hard-coded his (in an FBNconstants class), and he made a 154 (lost a point on documentation ).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic