This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Editable JComboBox in JTable not working without hitting Enter Key

 
Priya Sri
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a problem using an editable JComboBox as cell editor in a JTable.

When i edit the combo and then I press the TAB or ENTER key then all works fine and the value in the TableModel is updated with the edited one,
but
if i leave the cell with the mouse
or
traverse to another cell through arrow keys
or
click on any other cell, the typed value is going off

and the value is not passed to the TableModel. Why ? Is there a way to solve this problem ?

Regards
Priya Sri
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Next time I suggest you SearchFirst because I have posted this code at least 2 or 3 times before, in answer to similar questions.
 
Priya Sri
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added this line. But it is not working.
Can you describe in detail.
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ehm sorry. "val" should be Boolean.TRUE.
 
Priya Sri
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

Tried this. but no change...

If you have an examples of editable Jcombobox in JTable working without hitting enter key... I searched in this site as well.. but not found useful links. please post that if you have any.

Example : Jcombobox has 3 choices. On selecting 3 rd choice, it should become editable and user should key the value. Now at this point, user move the tab or click on the mouse, the entered value should be selected in the jcombo box.

But jcombobox is taking the value only on click of enter key.

Thanks.
 
Alfred Brookman
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have _exactly_ the same problem. i already wasted hours to find a solution, but no luck.
i would be glad for any help!

while implementing my own CellEditor i found out, that getCellEditorValue() is called before the editable combox has "updated" the string. so getSelectedItem() still returns the old value but shortly after that it would return the right value!
somehow there should be a method like "combobox.stopEditing()" or something...


my example:


EDIT: I found a solution! This does the trick:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic