Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Layout Manger for 1 or 2 tables

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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

 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic