• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set JComboBox items in a JTable.

 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JTable that contains two columns. I use a JComboBox in column 1. I follow the example in Swing Tutorial. However, i am trying to display an appropriate item among JComboBox's items for every row in JTable. I assume i have to iterate throught all rows in the table, in each row i have to extract the object in column 1 and call setSelectedItem() on this JComboBox object. However, i am not sure the way i setup the column according to the tutorial will allow me to achieve my goal. Also, how can i get the JComboBox object in a column? Thanks.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to call setSelectedItem. If you set the value of the cell it takes care of that for you setValueAt() method. I am not sure what problem you are having.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!