This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollPane cuts off table

 
mabel foo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change to
 
Rob Camick
Ranch Hand
Posts: 2580
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to give a hint to the scrollPane about how big you want the viewport to be:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic