Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

problem on JTable

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've a JTable, which saves/retrieve the entered values to the Database. The problem is when i edit a cell and change the value, It's not actually changed as when i'm retireving it, it still shows me the old value..........but if i change the focus from the editing cell to some other cell, It saves the changed value.
in another words if i leave the cursor in the editing cell and hit save, it doesn't actually change and still save the old value.
Any clues on fix for this....
Thanks in advance
-N.
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is a bug in JDK 1.4.1 which results from the former ((half-)fixed) bug, that the editor stayed in action even when the JTable lost focus. now the Editor is cancelled instead of stopped when the JTable loses focus.
see bug report http://developer.java.sun.com/developer/bugParade/bugs/4503845.html
 
Jain Neeraj
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i couldn't get the solution ...Is it fixed? i tried stopCellEditing but that didn't help...
Is there a fix for this problem?
Thanks,
N.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, there are some comments on the different bug repords where people have provided some patches but they are all quite "dirty". there is no clean workaround.
if you have the possibility switch back to 1.4.0 (this should be sufficient, I think). you will then need to stop the editor yourself when the table loses focus. but then again, you _can_ stop it.
 
Jain Neeraj
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i forgot to mention that i'm using jdk 1.3.1
....
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, I forgot. there is a workaround suggested by sun (ok, for them it's not a workaround).
catch the lostFocus event for JTable. the event is dispatched before the JTable loses focus (I hope, if not there is certainly another focus event dispatched before the focus is actually transfered). the editor will be active by then. get the value that is displayed by the editor, transfer the focus and set the value in the specific cell to the one you got from the editor.
here is the bug report with the suggestion (see the evaluation field)
http://developer.java.sun.com/developer/bugParade/bugs/4706881.html
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hm, 1.3.1
and stopCellEditing didn't work?
anyway, I paste you this sample code I thought of would work with lesser 1.4.1:

can you check whether the table really is editing (returning isEditing() == true) when you think it is?
 
Jain Neeraj
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much buddy i got it working
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic