tags:

views:

35

answers:

2

I have two tables. One table is a fixed column(ie. the table will not have any impact on the scrolling of scrollbar of another table). These two tables have to be commonly scrolled by a vertical scrollbar.Any idea or suggesstion or examples?

This is a continuation of the previous question. Fixed Column The answer for which is here FixedColumn.java

+1  A: 

There is a simple solution to this problem. Just put your "fixed column" table into "row header" decoration area of scroll pane used for the second table. it should something like following:

JTable table1 = new JTable();
JTable table2 = new JTable();
JScrollPane scrollPane = JScrollPane(table2);

JViewport viewport = new JViewport();
viewport.setView(table1);
viewport.setPreferredSize(table1.getPreferredSize());
scrollPane.setRowHeaderView(viewport);
scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER,table1.getTableHeader());    

You can find more information at http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#decorations

eugener
+2  A: 

Fixed Column Table or Row Number Table give some ideas.

camickr