• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Layouts, Panel & Frame

 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,
I am Kajol & I wanted to know the difference between Layouts, Panel & Frame....
Can somebody give me an general example so that ot would be easy for me to map it in my brain....
Thanks in advance
Kajol
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kajol,
First of all Panel and Frame are not layouts they are containers. The major difference is that Frame includes window borders (i.e., title bar, resize corners, max/min/close button, etc) and Panel doesn't. Both containers can support any layout you want to use.
Frame is a subclass of Window therefore it inherits all the window functionality (i.e., close, open, show, hide).
By default Window and Frame use BorderLayout while Applet and Panel use FlowLayout.
Regards,
Manfred.
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manfred,
Thanks a lot for ur reply...
I want to ask u that can i use panel & Cardlayout in Frame...
Kajol
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kajol,
Yes you can use CardLayout in Panel or in Frame.
and you can have panels inside your frame or inside other panel.
hope this helps,
regards
deekasha
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deekasha,
thanks for ur reply...
Can u plese tell me can i have a panel, layout of which I set to CardLayout and panels inside that panel wherein i can set the this inner panel to any other laoyout than CardLayout
Kajol
 
Bill Prentice
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may nest as many panels within panels as you need, each can have its own layout. Remember that with CardLayout you need to control the view, think of a card index, it can have many cards but only one is visible at any one time. This means that you may need to control all your cards (screens) in a collection (an array for example) and display the appropriate screen according to some criteria.
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
Can you explain me with an example...
See I have added a panel in an Applet & in that panel I have set the layout to CardLayout....now I have to add the components and to organise the components in a proper format I will need to set the layout again is it....as by default it will take FlowLayout... or should I use a seperate panel to add the components and then set the layout of that panel to FlowLayout as I set the first panel to CardLayout...
Correct me as I want to implement it..in my project
Kajol
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kajol,
Yes you are right.
1) You have added a Panel P1 to your applet.
2) Layout of P1 is set to Card Layout.
3) Now You need another panel P2 .
4) set the layout of P2 whatever you want.
5) add your components (Buttons etc)to P2.
6) add P2 to P1.
and everything is done.
hope this helps.
I'm in hurry right now so can't give you working example.
regards
deekasha

regards
deekasha
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks deekasha,
What i will do is implement the above methodology in my program and get back to you..
Till the mean time if u can get some example for me please tell me....
Kajol
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic