>>>>> "David" == David M Karr <[EMAIL PROTECTED]> writes:

    David> I've noticed an annoyance with using JSpinner, particularly as a table 
editor.
    David> It works fine if you just use the up/down buttons to change the valiue.

    David> It also seems to work fine if you manually type in a number.  However, once 
you
    David> move out of the field, the edited value goes away and is replaced by the
    David> previous value.

I've done some more experimentation on this.  I was able to go further on the
idea of using a FocusListener because Kleopatra pointed out to me the new
"setSurrendersFocusOnKeystroke()" method on "JTable".  Using this, I could
ensure that the spinner actually gets focus and later loses it (actually, it's
the internal text field, not the spinner).  Unfortunately, what I found was
that just before the FocusListener is processed, the field has already been
reverted to its old value.

So, I found that the only practical solution is to set the internal text field
to uneditable.  In other words, to not allow manual editing of the text field.

I found that JSpinners outside of JTables don't have this problem, although I'm
not certain of the exact circumstances that makes this work and the other
scenario not work.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED]

_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to