File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Swing problem with JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing problem with JTable" Watch "Swing problem with JTable" New topic
Author

Swing problem with JTable

Matthew Alesi
Ranch Hand

Joined: Sep 13, 2006
Posts: 38
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!!


-Matt
Current CS undergrad
SCJP 5.0
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Topic is more related to Swing / AWT / SWT / JFace Forum.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing problem with JTable