• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

JPanel

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has got to be easy, but I'm not getting it.
I am displaying a JTable in a JPanel. I am setting the size of the JTable using:
setPreferredScrollableViewportSize( new Dimension( 685, 180 ) )
...but what I'd really like is to have it sized to fit the display area of the JPanel. How do I get that Dimension?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
Use the JPanel layout to perform it for you. If you set the JPanel layout to BorderLayout you can add your JTable to the CENTER (default if not specified) then it will work for you.

That way your table will be the size of the panel!
Regards,
Manfred.
 
Peter Lyons
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred!
That works.
Do you have an idea how to do the same thing when I'm placing a JPanel in a tab on a JTabbedPane? It doesn't look like a layout manager can be used for that.
Thanks again...
Peter
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think panels within panels
 
Peter Lyons
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you, Mike and Manfred...
I appreciate the help!
Peter <--- trying to think like a JPanel
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!