简体   繁体   中英

How to set JScrollPane Layout to be the same as JTable?

Tabel1.setModel(new DefaultTableModel(x,y));
JScrollPane pane = new JScrollPane(Tabel1);

When I run the program the scrollpane appears bigger than the table. How can I make the scrollpane layout the same as the table?

  • how i can make scrollpane layout the same of table??

if your JTable contains only a few rows

table.setPreferredScrollableViewportSize(table.getPreferredSize());
  • Tabel1.setModel(new DefaultTableModel(x,y));

use Java Naming Conventions correctly, then not Tabel1 but tabel1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM