Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JCombobox in JTable cell does not dropdown

 
Rob Elliott
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My JTable contains two columns, the 2nd column contains an extended JCombobox. The problem appears when the table contains multiple rows. When the table is displayed and I click on one of the Comboboxs it drops down as it should and I make a selection. I then click on another Combobox and the combobox is highlighted but the selection list does not drop down. I must click on it a 2nd time to make it drop down. Not sure how to resolve this one???
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that possbily I know the reason for this, but not the solution. The reason I think is because the first time you click the Cell containing the JComboBox, you are simply selecting the Cell, then you are able to click the JComboBox.
So hopefully someone knows why this is.
 
Rob Elliott
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was that stopcellediting was not being called until the 2nd combobox was clicked, probably invoked by lostfocus. The solution was to implement ItemLister interface in my custum editor class (derived from DefaultCellEditor), and the ItemListener to the private Combobox member and in teh ItemStateChanged handler call stopCellEditing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic