Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JTable CellRendererPane placement

14 views
Skip to first unread message

FredK

unread,
May 8, 2013, 4:34:19 PM5/8/13
to
I have a JTable with two columns and a JTableHeader.
The left column contains strings, and the right column contains JTextFields.
Clicking on a header sorts the rows.

If I click in one of the text fields to begin editing it ( say, for
instance, in row 7), and then click in the header to sort the table,
the CellRendererPane (and the CellEditor) remain over the original position
(row 7), even though that field is now in row 2. When I click in the editor
it *LOOKS* like I am editing what is now in line 7, but in fact I am still
editing what is now in row 2.

If I click over any other row, or resize the table, everything gets
updated and the editor moves to the proper position.

After sorting, how can I ensure that the editor moves be over the
new position?
--
Fred K

Daniele Futtorovic

unread,
May 8, 2013, 6:59:19 PM5/8/13
to
Unless someone else has an answer ready for you, could you post an SSCCE?

--
DF.

John B. Matthews

unread,
May 8, 2013, 8:15:00 PM5/8/13
to
In article <kmel58$8tq$1...@dont-email.me>,
Daniele Futtorovic <da.fut...@laposte-dot-net.invalid> wrote:

> On 08/05/2013 22:34, FredK allegedly wrote:
> > I have a JTable with two columns and a JTableHeader. The left
> > column contains strings, and the right column contains
> > JTextFields. Clicking on a header sorts the rows.

It may help to distinguish between the data types stored in the
model and the renderer/editor applied by the view.

> > If I click in one of the text fields to begin editing it ( say,
> > for instance, in row 7), and then click in the header to sort
> > the table, the CellRendererPane (and the CellEditor) remain
> > over the original position (row 7), even though that field is
> > now in row 2. When I click in the editor it *LOOKS* like I am
> > editing what is now in line 7, but in fact I am still editing
> > what is now in row 2.
> >
> > If I click over any other row, or resize the table, everything
> > gets updated and the editor moves to the proper position.
> >
> > After sorting, how can I ensure that the editor moves be over
> > the new position?
> >
>
> Unless someone else has an answer ready for you, could you post
> an SSCCE?

In addition, note that sorting may expose the difference between
model and view coordinates, "NOTE: When using a sorter, always
remember to translate cell coordinates."

<http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
0 new messages