[SWINGX-1422] JXTable.setColumnSequence() works incorrectly as of 1.6.2, possibly earlier Created: 25/Mar/11  Updated: 28/Mar/11  Resolved: 28/Mar/11

Status: Resolved
Project: swingx
Component/s: Table
Affects Version/s: 1.6.2
Fix Version/s: 1.6.3

Type: Bug Priority: Blocker
Reporter: tjwolf Assignee: kleopatra
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: Not Specified
Original Estimate: 0 minutes

Environment independent: happens on Windows XP, Mac OSX, Windows 7 with a variety of JREs (observed in 1.6_17 thru 1.6_24).

Attachments: Java Source File Main.java    
Issue Links:
depends on SWINGX-1423 DefaultTableColumnModelExt: remove mu... Resolved


Our application's JXTable "state saving" is broken as of swingx 1.6.2. Before this release, our users could save the visibility of columns (among other things). Now this no longer works. If you run the attached program, simply hide one of the columns using JXTable's column control popup and click on "Get State". This extracts the column-related information from the JXTable. Now use the column control popup to make the column visible again. If you click on "Set State Column Sequence", the previously saved state gets restored, so the column you previously hid should disappear again- but it doesn't....at least not with swingx 1.6.2. The problem appears to be the JXTable.setColumnSequence() call. If we leave that out (in the test program, click the "Set State No Column Sequence", the column does disappear as expected. Unfortunately, that's not a good workaround as we're also trying to save/restore column order as part of our state.

Comment by kleopatra [ 28/Mar/11 ]


hmm ... did that ever work?

Because, on first look it seems to be a mis-usage of the setColumnSequence: what it is intended to do is to change the initial insertion order (which by default is the same as the sequence in the model). As you noted, there is no api to restore user order of columns, you have to do it yourself. See XProperties in my incubator.

That said, I'm puzzled about the visible/hidden property - shouldn't be touched in setColumnSequence. Need to dig a bit


Comment by tjwolf [ 28/Mar/11 ]

Hi Jeanette,
Yes, this used to work - at least in 0.9x. Both I and Wolfgang (Jyloo - maker of Synthetica) verified it (Jyloo deploys swingx with their Synthetica Add-ons, so I asked him which version of swingx they had been using prior to 1.6.2 - he said it was 0.9 or 1.0).

If you don't have a 0.9x release handy and want to try with the above test case, I could attach the jar to this issue.

Thanks for looking into it. If you can think of an easy workaround (or the "proper" way to restore user column order), let me know.

Comment by kleopatra [ 28/Mar/11 ]


the underlying issue was #1423 (see the depends on link). That was indeed changed after 1.0, fixed now. Your example is working as far as the hidden column is concerned, but probably not doing what you expect: as I already said, the setColumnSequence is meant to change the insertion order of the columns, which is the same as shown in the column control. Don't use the method if you only intend to change the visual order of the columns. See XProperties on a how-to.

Will close this as fixed in a while - waiting for your objection, if any


Comment by tjwolf [ 28/Mar/11 ]

Thanks for fixing the visibility thing so quickly. Not sure I understand your suggestion to look at XProperties on a how-to: can you provide a link? Will it show the "proper" way of saving/restoring visual order of the columns?

I imagine your swingx-1423 fix will be in 1.6.3? When is that due out?

Thanks as always,

Comment by kleopatra [ 28/Mar/11 ]


XProperties are in my incubator section, in the application package. Unsupported, as everything there The main thingy to keep in mind is the insertion vs. the visual sequence: the former is assumed to be kind of "fixed" (aka: generated by add/removeColumn). The latter is the user customization, it's generated from the former (by the user) by invoking moveColumn. On storing, you'll have to store that visual index along with the other properties. On restoring, there's no way (none that I'm aware of) but actually call moveColumn until you get the old user sequence.

That's ugly .. feel free to file a rfe Closing this as fixed.


PS: no concrete plans for the next release

Generated at Wed Feb 22 11:22:59 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.