• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Layout Manger for 1 or 2 tables

 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a dialog that will contain 1 or 2 tables. In the case that there are 2 tables, I need them both to be viewable in the dialog. In the case of 1 table, I only want to see 1 table. I've been using setVisible on the table panels to make them appear and disappear. The problem with this is that when they're is only 1 table present, where the other table is all gray. Is there a way to alter this, so I see only the 1 table and not all the blank gray space and the table?

Thanks for any help. I'm currently using a gridlayout for this, but it's not really what I'm looking for.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try setting the layout to BorderLayout()
add table1 to BorderLayout.CENTER
add table2 to BorderLayout.EAST (or wherever)

if only table1 is showing, it should occupy all the space
if both are showing, table1 will get whatever space is left over from table2's
preferredSize, so you may have to tweak table1's preferredSize to match that of
table2, if you want both tables to appear the same size

something like this

 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help guys.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic