Reputation: 609
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.
Upvotes: 2
Views: 1672
Reputation: 13
You can change the JScroller preferred size because a table is often put inside of a scroller.
scrollerPhone.setPreferredSize(new Dimension(600, 400));
Upvotes: 1
Reputation: 109815
override table.getPreferredScrollableViewportSize(new Dimension(int, int));
change JPanel
s default LayoutManager FlowLayout
(implemented in API) to BorderLayout
or GridLayout
Upvotes: 4