Ok so I have this code:
//adding the panel which will hold the order table
JPanel orderPanel = new JPanel();
right.add(orderPanel);
JTable order = new JTable(orderData, orderColumnNames);
JScrollPane orderPane = new JScrollPane(order);
orderPanel.add(orderPane);
And I want to be able to remove this space :
I guess the space is made by the JScrollPane but i can't find any method to resize the JScrollPane to the JTable's size
解决方案
For the reasons adduced here, don't of invoke setPreferredSize(). Instead, override getPreferredScrollableViewportSize() to return the desired size.