Вопрос

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 :

The description of what I want to remove

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top