DanJhonatan
DanJhonatan

Reputation: 15

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

i'm a student of science computing and I have a doubt ..

Is it possible to have 1 JScrollPane with 2 JTable inside? And, when I move the scroll, the table 1 and table 2 move together?

Upvotes: 1

Views: 485

Answers (2)

mKorbel
mKorbel

Reputation: 109813

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

  • not good idea, because JScrollPane is designated to nest only one JComponent, any attempts have got issue with natural scrolling

  • and JTable in is designated has inside the JScrollPane

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

  • yes is simple and possible, to create two JTables with JScrollPanes, then to use AdjustmentListener added to JScrollBar(s), derived directly from both JScrollPane, example for AdjustmentListener

Upvotes: 2

Toilal
Toilal

Reputation: 3399

Add both JTable instances to a JPanel with BorderLayout, using NORTH and SOUTH constraints, and then add the JPanel to JScrollPane.

Upvotes: 0

Related Questions