Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing problem with JTable

 
Matthew Alesi
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks all!!
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Topic is more related to Swing / AWT / SWT / JFace Forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic