No horizontal cover at JTable JScrollPane
-
I add JTable to JScrollPane. Set the regime
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
That the table would cover the entire scrub. When the columns are small, it's beautiful, they're stretching and they're all wide. But if there's a lot of them, they narrow it down and it doesn't look beautiful:
You can certainly give a minimum width for each column:
getColumnModel().getColumn(1).setMinWidth(75);
It happens:
But there's another problem. It doesn't work horizontally. The mode is standing.
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Square is, but you can't twist it. I know that all these problems can be solved with the following code:setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
But then the columns are growing up and the table is clicking on the left upper corner of the scrub. Anyway, I need to see if the columns are small, they're spreading all over the breadth, and when there's a lot of them, so they don't narrow down a certain amount. And what a horizontal scrub would work. Can I do that sometime?
-
For interaction
JScrollPane
responds to the interfacejavax.swing.Scrollable
♪♪ https://stackoverflow.com/a/6104955 Participant https://stackoverflow.com/users/131872/camickr en.SO shows how to redesign the method
getScrollableTracksViewportWidth
Ooh.JTable
in order to achieve the:public boolean getScrollableTracksViewportWidth() { return getPreferredSize().width < getParent().getWidth(); };
Method returned
true
if the screen panel is to establish the width of the table on the size of the visible window (viewport).Decision finalized https://stackoverflow.com/a/15240806 the width of the first column, if the size of the table did not exceed the size of the apparent area, could not be changed without further refinement.