Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on populating combobox destination

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to automatically load the destination combobox from the database but I only want unique names any suggestion on how to do this and my other question is regarding JTable I would like to click on the JTable row and set the values in the rows to text fields origin and destination and seats available any ideas how to tackle this
Thanks Lisa
 
Rahul Rathore
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may define a method String[] getDistinctValues(int fieldNum) in the Data class. Implement this method as follows:-iterating through every record. Retrieve the value stored in that field for each record. Use a local variable of type Set, and add every such value to the Set. The Set will ensure that only unique values are added. Then finally convert the Set to an array using return (String[])set.toArray(new String(0)) method and return a String[] containing unique values of the field. Now from the client call this method by supplying the field number of the destination field.
I did not understand the second part of your question.

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Rahul I will get this put together.
Thanks Lisa
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic