• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to set JComboBox items in a JTable.

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic