Re: JTable Editing not take effect until hit Enter
- From: "Richard Reynolds" <richiereynolds@xxxxxxxxxxxx>
- Date: Sat, 26 May 2007 12:26:54 GMT
"Steve W. Jackson" <stevewjackson@xxxxxxxxxxx> wrote in message
news:stevewjackson-AA21FB.16043624052007@xxxxxxxxxxxxxxxxx
In article <newscache$f70kij$iib$1@xxxxxxxxxxx>,
Thomas Fritsch <i.dont.like.spam@xxxxxxxxxxx> wrote:
RC wrote:
I found out if you editing a JTable cell without hitThe problem is, that in this case the cell editor's stopCellEditing()
the Enter or Tab key. Then the new cell value won't take
effect. For example, a table cell value is "abc" and
you change it to "xyz".
method is not called. See also the API doc of
CellEditor#stopCellEditing()
Then when you read that tableYou have to call your cell editor's stopCellEditing() method at
cell value, it still "abc". You MUST hit the Enter or
Tab key, then you will get that table cell value as "xyz".
How can I force that table cell value as "xyz" WITHOUT
hit the Enter or Tab key?
appropriate
times (probably when the cell looses keyboard focus):
JTable yourTable = ...;
if (yourTable.isEditing())
yourTable.getCellEditor().stopCellEditing();
Or simpler: somewhere at the beginning you tell your JTable to do those
stopCellEditing calls automatically for you:
yourTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
I'm pretty sure that the default behavior does this already (though I
could be mistaken). The OP's description sounds like he's trying to do
it without a focus change or edit completion event. Or maybe he's
expecting the edit to get accepted when closing the containing dialog or
frame, which does not happen. The default behavior there is to cancel
the edit and discard it.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama
Maybe he could write a CaretListener and update the value each time the
cell's field is updated? I vaguely remember having to do something like
this, I think JFormattedTextFields were involved too.
.
- References:
- Re: JTable Editing not take effect until hit Enter
- From: Steve W. Jackson
- Re: JTable Editing not take effect until hit Enter
- Prev by Date: Re: "fading" graphics using Graphics2D
- Next by Date: Re: JComboBox.setSelectedItem() doesn´t update selected Item?
- Previous by thread: Re: JTable Editing not take effect until hit Enter
- Next by thread: Detecting Focus In A Tabbed Pane
- Index(es):
Relevant Pages
|
|