• Post Reply Bookmark Topic Watch Topic
  • New Topic

Nested panels & gridbaglayout  RSS feed

 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Iam using gridbag layout and have run in to problems.

The following is my scenario:

My top level container is a JFrame.
To the JFrame,I have added a Jpanel & made it the content pane of the JFrame.
For the panel,I have used the GridBagLayout.

Now to the panel,I have added a toolbar and a splitpane(top level).

The splitpane is a nested pane with another splitpane inside & another component.

My questions ,here are

[1]As a rule ,is it recommended to set a min size,max size & a preferred size for each of the component or container put in the contentpane.

[2]I have provided the gridconstraints only for the toolbar & the toplevel splitpane.Is that sufficient or is it necessary to provide it for all the other containers & components as well.

for eg:- in the above said toolbar,Iam adding some buttons.I havent set any layout for the toolbar, co's the containing panel is set with the gridbaglayout.Is that sufficient .If not,what is the right thing to do...

Its really difficult to explain it in words.I have developed a quick & dirty application depicting the above behaviour.

Would be nice,If I could send the application to any one of you....Would appreciate it very much...

Thanks.......
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[1]As a rule ,is it recommended to set a min size,max size & a preferred size for each of
the component or container put in the contentpane.

Generally, no. Sometimes the minimumPS and maximumPS come in handy and in BoxLayout they
seem to be used more often than in others. The preferredSize is often used to provide size
hints in Swing and especially in layouts that respect a child components preferredSize such
as GridBagLayout and FlowLayout.
[2]I have provided the gridconstraints only for the toolbar & the toplevel splitpane.Is that
sufficient or is it necessary to provide it for all the other containers & components as
well.

You only need to provide the constraints for child components that are added to a container
whose layout manager is GridBagLayout. Layout managers of children of the container aren't
concerned about the parent containers constraints per se. So, no.
Its really difficult to explain it in words.I have developed a quick & dirty application
depicting the above behaviour

Okay, let's have a look.

edit: Correct the formatting.
[ April 25, 2007: Message edited by: Craig Wood ]
 
Arun Sanker
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Craig.But How can I send my application to you.The forum contains no attachment functionality.....
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason there is no attachment facility is that this is a public forum. We don't send code to one another, we post it (preferably using code tags and shortened only showing the problem area) so everybody can read it and learn from it.

CR
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!