两个JTable共用滚动条

发布于 2024-09-07 03:10:26 字数 366 浏览 3 评论 0原文

我有两张桌子。一个表格是固定列(即该表格不会对另一表格的滚动条滚动产生任何影响)。这两个表通常必须通过垂直滚动条滚动。有什么想法、建议或示例吗?

这是上一个问题的延续。 固定列 答案就在这里 FixedColumn.java

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹎☆浅夏丿初晴 2024-09-14 03:10:26

固定列表行号表给出了一些想法。

不及他 2024-09-14 03:10:26

这个问题有一个简单的解决方案。只需将“固定列”表放入用于第二个表的滚动窗格的“行标题”装饰区域即可。它应该类似于以下内容:

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());    

您可以在 找到更多信息http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#decorations

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文