Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting latest value from combobox

D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have an example in which there is a JComboBox in one of the columns of a JTable. This combo box can have only values - X,Y or Z. However, when I try to prepopulate the table, I pass a wrong value "A" to the combo box column. This column has an associated editor and renderer. And as per the default working of a combo box, it shows the value as "X" (as that is the first option) when I pass "A". I have an array of strings maintained as a member variable in the model class of this JTable. This member variable is initiallized with "A". So, getValueAt method at this row and column shows "A" only, not "X".

The problem now is, I want to know the actual updated values in the JTable. The value "A" could not be populated, and value "X" is shown in the UI. However, if I want to get this value "X", how do I achieve that? I know I should just try to get the selected item of the combo box. What I wanted to know is, whether I should put that getter method in the editor class or the renderer class of this JComboBox column. I think my question would just help me understand how the value is getting set to default value in the first place.( what does the setting? editor or renderer)

Can someone help me understand this please?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic