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
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.
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
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.
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
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