File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JScrollPane cuts off table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollPane cuts off table" Watch "JScrollPane cuts off table" New topic

JScrollPane cuts off table

mabel foo

Joined: Oct 07, 2009
Posts: 8
Hi, I have a JTable inside a JScrollPane and the table gets cut off at the bottom.
The JScrollPane is inside JPanel, and JPanel is inside GridBagLayout.

The table is displayed properly if I remove JScrollPane though.

This is the code for adding JPanel into GridBagLayout.

I've tried using setBounds and setPreferredSize on JScrollPane but it doesn't work.

Please help! Thanks!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10651

Change to

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2267
You need to give a hint to the scrollPane about how big you want the viewport to be:

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: JScrollPane cuts off table