From: John B. Matthews on
In article <hcsunv$u5s$03$1(a)news.t-online.com>,
Michael Rauscher <michlmann(a)gmx.de> wrote:

> Felix Natter wrote:
> > Can you think of a way to get arounds this, like modifying the
> > validation order?
>
> If my theory is true, the following should work
>
> tblSP = new JScrollPane(dataTable) {
> public boolean isValidateRoot() {
> return false;
> }
> };

Indeed, it works perfectly in Noel's example. Thanks!

On review, I see that JRootPane, JScrollPane and JSplitPane all return
true for isValidateRoot(). In contrast, JTextField's isValidateRoot()
returns false when it's contained within a JViewport, perhaps for a
similar reason.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: Felix Natter on
"John B. Matthews" <nospam(a)nospam.invalid> writes:

> In article <hcsunv$u5s$03$1(a)news.t-online.com>,
> Michael Rauscher <michlmann(a)gmx.de> wrote:
>
>> Felix Natter wrote:
>> > Can you think of a way to get arounds this, like modifying the
>> > validation order?
>>
>> If my theory is true, the following should work
>>
>> tblSP = new JScrollPane(dataTable) {
>> public boolean isValidateRoot() {
>> return false;
>> }
>> };
>
> Indeed, it works perfectly in Noel's example. Thanks!

First of all thanks a lot for all the helpful replies, this
solution works perfectly :-)

However, in order to make resizing columns work, the following is
necessary:
headerTable.setTableHeader(dataTable.getTableHeader());
(I currently don't know why)

However, when using the above line, the sorting method provided
by Java 1.6 will not work any more. Luckily, the following solution
for java 1.5 works perfectly:
http://stackoverflow.com/questions/591610/jtable-sorting-rows-in-java-1-5

Now everything works: column resizing, sorting, fixed rows, no update
problems :-)

Thanks again!
--
Felix Natter
From: Michael Rauscher on
Felix Natter wrote:
> "John B. Matthews" <nospam(a)nospam.invalid> writes:
>
>> In article <hcsunv$u5s$03$1(a)news.t-online.com>,
>> Michael Rauscher <michlmann(a)gmx.de> wrote:
>>> tblSP = new JScrollPane(dataTable) {
>>> public boolean isValidateRoot() {
>>> return false;
>>> }
>>> };
>> Indeed, it works perfectly in Noel's example. Thanks!

In fact, it works for your SSCCE, too.

> However, in order to make resizing columns work, the following is
> necessary:
> headerTable.setTableHeader(dataTable.getTableHeader());
> (I currently don't know why)

If you apply it to your SSCCE, resizing and sorting will work as expected.

Bye
Michael
From: Christian Kaufhold on
John B. Matthews <nospam(a)nospam.invalid> wrote:

> On review, I see that JRootPane, JScrollPane and JSplitPane all return
> true for isValidateRoot(). In contrast, JTextField's isValidateRoot()
> returns false when it's contained within a JViewport, perhaps for a
> similar reason.

JTextField returning true at all from isValidateRoot() is a misguided
broken optimization.
From: Christian Kaufhold on
Followup-To: comp.lang.java.gui

Noel <prosthetic_conscience1(a)yahoo.com> wrote:

> JTable table = new JTable(dataModel);
> table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
> table.setAutoCreateRowSorter(true);
>
> JTable headerTable = new JTable(headerModel,
> table.getColumnModel());
> headerTable.setRowSelectionAllowed(false);
>
> JTable footer = new JTable(footerModel,
> table.getColumnModel());
> footer.setRowSelectionAllowed(false);
>
> container.add(headerTable);
> container.add(new JScrollPane(table));
> container.add(footer);
> getContentPane().add(container);
> }

There is a more general problem here because all three tables will layout
the column widths and possibly interfere with each other. I would disable
the column layout for the header and footer.

See the last section of
http://www.chka.de/swing/table/column-headers/JTable-JTableHeader.html