开发者

JTable frozen columns not scrolling (Java 1.6)

I am migrating an application from java 1.5 to 开发者_运维知识库1.6 (yeah, I know).

We have a table with some frozen columns. Constructed like so (roughly)

JScrollPane tablePane = new JScrollPane();
JTable mainTable = new JTable();
JTable frozenTable = new JTable()
JPanel rowHeaderPanel = new JPanel();
rowHeaderPanel.add(frozenTable);

tablePane.setRowHeaderView(rowHeaderPanel);
tablePane.setViewportView(mainTable);

(Table models for the main and frozenTable always have the same number of rows)

This worked as we wanted under java 1.5, ie: we had a data table with a number of frozen columns on the left hand side. Scrolling the pane vertically scrolled both tables in unison.

Without any code changes other than moving to java 1.6 we now have an intermittent and (in dev environment) unreproducible bug.

Sometimes when you vertically scroll only the main table scrolls - the frozen table does not scroll at all. The tables appear unlinked.

Has anyone seen anything like this before?


The intermittent nature of the problem should prompt one to verify that the GUI components are constructed on the event dispatch thread. The move to 1.6 may have changed the timing just enough to expose such an anomaly.


I have not seen anything like this before and since it is unreproducible, it will be hard to debug. I suggest paring it down to as small of an example as possible (basically a SCCEE) and see if you reproduce the behavior. If it still intermittent exists then it might be something to do with 1.6 but I doubt it. If it no longer exists, then it might be something else happening in the background at the same time.


I agree, this is a tough problem. But the way we do it is slightly different and it currently works in production under Java 6. So it may help to solve the issue IMO.I tried to use the same variable names as in initial code. Here is the code we use:

JViewport viewport = new JViewport();
viewport.setView(frozenTable);
viewport.setPreferredSize(frozenTable.getPreferredSize());
tablePane.setRowHeaderView(viewport);
tablePane.setCorner(JScrollPane.UPPER_LEFT_CORNER,frozenTable.getTableHeader());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜