Just another blog.

JTable with fixed columns

Another solution

JTable with fixed columns is really problem. There is no “one-and-the-only-right” solution for fixing one or two columns while leaving others scrollable.

There are two solutions for this problem.

Two tables solution

This solution uses two tables, one for fixed columns and other for the rest. This solution is described in nice article Fixed Column Table and the same solution is used in JXTable from xframe project.

This solution works nice, but there is one small UI (maybe more visual) problem. Scrollbar is visible only on the part of table, which is scrollable.

Two tables solution

Two tables solution

Another solution

“Another” solution is described in Freezable JTables (are they extreme?). This solution uses custom component, which is exactly the same size like the fixed columns and the fixed columns are painted into this component. And everything looks like the JTable supports fixed columns.

The problem with this solution is, that the fixed columns are “image” :-) You can find some difficulties when you moved with scrollbar and tried to doubleclick on some cell in the fixed column. You will edit another cell, hidden under this “image” :-)

Another solution

Another solution

I will continue with searching :-)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>