This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm creating a program that involves making a page of sorts. My "page" is a JPanel using BoxLayout (vertically), with a JLabel title, a JTableHeader and JTable full of data, and a JPanel at the bottom with some more info inside. The entire page panel is wrapped inside a JScrollPane and placed in my a JFrame. The entire thing is meant to look like almost like a website; you don't scroll the table itself, you scroll the whole page.
The problem is the table width. The table, by default sets its width to that of the panel it's in, but since the values don't nearly fill up all this space it looks astronomically wide. Every kind of setSize, etc. method that exists requires a height in addition to a width, but I don't want to set the height; the number of table rows is variable.
Can anybody help me figure out a simple way to set the width of my JTable so that it doesn't take over the pane?