问题
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
回答1:
For the reasons adduced here, don't of invoke setPreferredSize()
. Instead, override getPreferredScrollableViewportSize() to return the desired size.
来源:https://stackoverflow.com/questions/21942213/how-can-i-resize-a-jscrollpane