• 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

Editable JComboBox in JTable not working without hitting Enter Key

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have added this line. But it is not working.
Can you describe in detail.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ehm sorry. "val" should be Boolean.TRUE.
 
Priya Sri
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic