是否可以将 2 个 jtables 插入到 JAVA 中的一个 jscrollpane 中?

Is it possible, to insert 2 jtables into only one jscrollpane in JAVA?

我是科学计算专业的学生,​​我有一个疑问..

1个JScrollPane里面有2个JTable可以吗? 而且,当我移动卷轴时,table 1 和 table 2 一起移动?

使用 NORTH 和 SOUTH 约束将两个 JTable 实例添加到带有 BorderLayout 的 JPanel,然后将 JPanel 添加到 JScrollPane。

Is it possible to have 1 JScrollPane with 2 JTable inside?

  • 不是个好主意,因为 JScrollPane 被指定只嵌套一个 JComponent,任何尝试都会遇到自然滚动的问题

  • JTable在指定里面有JScrollPane

And, when I move the scroll, the table 1 and table 2 move together?

  • yes 简单可行,用 JScrollPane 创建两个 JTable,然后使用 AdjustmentListener 添加到 JScrollBar(s),直接派生自JScrollPaneexample for AdjustmentListener