Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in border layout.  RSS feed

 
Punit Jain
Ranch Hand
Posts: 1028
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i add two classes with border layout to my frame, one is in center and one is in south but in the border layout "If nothing has been added to a region, the neighboring regions expand to fill that space."
here also this is happening, but i want the space in the west and east also, i mean my class which is in center should not expand the neighbor space(ie. west and east),
how to do this???
 
Punit Jain
Ranch Hand
Posts: 1028
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what i am doing is, i m just creating three blank classes, and adding them to all the sides with different background color, is there anything else i can do??
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, you don't add classes to a GUI, you add Components.

is there anything else i can do??

Use a layout more appropriate to your need? but there's nothing wrong with 'padding' a BorderLayout in the way you describe.

For empty space around the outside of a Container, a suitably dimensioned EmptyBorder would be my choice.
 
Punit Jain
Ranch Hand
Posts: 1028
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Use a layout more appropriate to your need


Actually i want space around my center in all the side, therefore border is layout is suitable for me, i think...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Actually i want space around my center in all the side

this is one area where GridBagLayout makes it easy
(but it won't really suit if you want different colors)

simple demo
 
Punit Jain
Ranch Hand
Posts: 1028
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, GridBagLayout looks much easier here, but i need to make some drawing also in south direction, so i think adding classes to borderLayout is good, m i right???
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> but i need to make some drawing also in south direction, so i think adding classes to borderLayout is good, m i right???

probably would be easier working with an entire panel in south.
 
Punit Jain
Ranch Hand
Posts: 1028
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes that i m also doing, i added panel(class) to south direction, but the thing is i also have to add panels to other directions as well in border layout, but the drawing i am doing in south direction only..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!