A customer of mine would like to have the possibility to freeze columns in a JTable.
I know this problem has been addressed 2 billion times, but the standard reply is "Use 2 tables", and unless I missed something in that solution, it doesn't suit my need.
The main problem (besides having to rewrite quite a bit of code, but i'd do it if needed) is that if I use two tables, I did not find a way to have a proper "cross-selection" (ex: if I click and start dragging to select cells of the first table, and I reach the "invisible" barrier between both tables, the mouse won't go further, and it's a problem if I want to also select in one drag data from the other table). That is a no-go to my customer.
Is there any workaround for that problem that I did not figure out?
If not, does anyone know about some other solution? Maybe some 3rd party library (preferrably an extension of/a custom JTable, then I can integrate it easily) ? Even if I got to pay, if you know of any such lib it could save me quite a deal of troublesome adventurous coding in GUI fields I don't know so much about.
michael carton wrote:If not, does anyone know about some other solution? Maybe some 3rd party library (preferrably an extension of/a custom JTable, then I can integrate it easily) ? Even if I got to pay, if you know of any such lib it could save me quite a deal of troublesome adventurous coding in GUI fields I don't know so much about.
Which implementations have you already researched, that didn't suit your purpose?
There are no new questions, but there may be new answers.
Yes, exactly, sorry that I forgot to mention that; I am indeed referring to an Excel-like "freeze pane" functionnality.
The idea is that my customer would like to get a couple of columns at the start of the JTable which don't scroll, while the rest of the table does. And since I've barely ever worked with viewports and the likes (well, I'm not even sure if that's really the mechanism at work), and heard a couple of times that it is quite a tedious work to implement that myself (at least in a non-buggy way) and my time-budget is not too high, I'd prefer to avoid that, if possible (even if it means using a commercial library).
@Darryl: what I tried so far is something I found over the internet. It consists in having two tables next to each other that share the same model. The "scrollable table'''s column model is stripped from all the unrelevant columns, while they are added to the "fixed table", and then the "fixed table" is set as the row header of the "scrollable table".
I thought this solution rather satisfying, but unless I missed some subtelty, I didn't find a way to do mouse-selections over both tables at the same time, and sadly my customer really wants that.
For instance, if I have a "fixed table" with two columns and a "scrollable table" with 5 columns, the customer would like to have the possibility to select with the mouse (or even keyboard) data from column 2, 3 and 4. In the tries I performed with this implementation, it is not possible (if the selection starts on table 1, I can select only the 2nd column because that's the last column of table 1 ; if I start on table 2, I can select only columns 3 & 4, because they're the first columns of table2).
Sadly, I didn't find a way to do that, but since that's a topic i'm not familiar with, it might be I missed something really simple there? If not, any known library/piece of code that does this or even any hint toward which mechanisms to search on (ex: viewports, and others if there are other things at work) would be a great help!
(below the latest implementation I tried, as found on some website (maybe even here, I don't remember))