Frage

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

War es hilfreich?

Lösung

For the reasons adduced here, don't of invoke setPreferredSize(). Instead, override getPreferredScrollableViewportSize() to return the desired size.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top