Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1680 > unrolled thread
| Started by | "RC" <rc@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:34 +0000 |
| Last post | 2011-04-27 15:34 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.java.gui
JTable Editing not take e "RC" <rc@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: JTable Editing not ta "Thomas Fritsch" <thomas.fritsch@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: JTable Editing not ta "Steve W. Jackson" <steve.w..jackson@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
Re: JTable Editing not ta "Richard Reynolds" <richard.reynolds@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
| From | "RC" <rc@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | JTable Editing not take e |
| Message-ID | <f34acc$m7d$1@news.nems.noaa.gov> |
To: comp.lang.java.gui,comp.l Hello dudes, I found out if you editing a JTable cell without hit 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". Then when you read that table 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? Thank Q very much in advance! --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Thomas Fritsch" <thomas.fritsch@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: JTable Editing not ta |
| Message-ID | <newscache$f70kij$iib$1@news.ops.de> |
| In reply to | #1680 |
To: comp.lang.java.gui,comp.l
RC wrote:
> I found out if you editing a JTable cell without hit
> 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".
The problem is, that in this case the cell editor's stopCellEditing()
method is not called. See also the API doc of CellEditor#stopCellEditing()
> Then when you read that table
> 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?
You have to call your cell editor's stopCellEditing() method at 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);
--
Thomas
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Steve W. Jackson" <steve.w..jackson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: JTable Editing not ta |
| Message-ID | <stevewjackson-AA21FB.16043624052007@individual.net> |
| In reply to | #1681 |
To: comp.lang.java.gui
In article <newscache$f70kij$iib$1@news.ops.de>,
Thomas Fritsch <i.dont.like.spam@invalid.com> wrote:
> RC wrote:
> > I found out if you editing a JTable cell without hit
> > 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".
> The problem is, that in this case the cell editor's stopCellEditing()
> method is not called. See also the API doc of CellEditor#stopCellEditing()
>
> > Then when you read that table
> > 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?
> You have to call your cell editor's stopCellEditing() method at 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
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Richard Reynolds" <richard.reynolds@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:34 +0000 |
| Subject | Re: JTable Editing not ta |
| Message-ID | <iIV5i.127$E9.13@newsfe6-gui.ntli.net> |
| In reply to | #1684 |
To: comp.lang.java.gui
"Steve W. Jackson" <stevewjackson@knology.net> wrote in message
news:stevewjackson-AA21FB.16043624052007@individual.net...
> In article <newscache$f70kij$iib$1@news.ops.de>,
> Thomas Fritsch <i.dont.like.spam@invalid.com> wrote:
>
>> RC wrote:
>> > I found out if you editing a JTable cell without hit
>> > 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".
>> The problem is, that in this case the cell editor's stopCellEditing()
>> method is not called. See also the API doc of
>> CellEditor#stopCellEditing()
>>
>> > Then when you read that table
>> > 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?
>> You have to call your cell editor's stopCellEditing() method at
>> 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.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web