• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic