user2007843
user2007843

Reputation: 609

making a jtable bigger to fit all data

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

Answers (2)

whoisagp
whoisagp

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

mKorbel
mKorbel

Reputation: 109815

  • override table.getPreferredScrollableViewportSize(new Dimension(int, int));

  • change JPanels default LayoutManager FlowLayout (implemented in API) to BorderLayout or GridLayout

Upvotes: 4

Related Questions