I currently have a JTable inside a JscrollPane inside a JPanel. No matter what I set the size of either of those 3 elements, the table always shows up as the same size. The JPanel is in BorderLayout and I am packing the frame. the reason I want to do this is because some of the data in my columns doesn't fit without having to make other columns way too small.
问问题
1241 次
2 回答
4
覆盖
table.getPreferredScrollableViewportSize(new Dimension(int, int));
将
JPanel
默认的 LayoutManagerFlowLayout
(在 API 中实现)更改为BorderLayout
或GridLayout
于 2013-04-29T13:48:35.707 回答
1
您可以更改 JScroller 首选大小,因为表格通常放在滚动条内。
scrollerPhone.setPreferredSize(new Dimension(600, 400));
于 2020-09-15T18:04:56.063 回答