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 来源: https://stackoverflow.com/questions/10551995/how-to-set-jscrollpane-layout-to-be-the-same-as-jtable