About layering JFrames JPanels and the whole deal with that?
hey i been making a JFrame window with a JMenuBar a JList and some other stuff but i can never seem to remember or figure out
what order they have to be layed can anyone tell me which windows or panels or what not can parent other windows
... I am sorry if what I ask don't make too much sense but I am trying my best to explain.
I need hieracy (excuse the spelling :( ) of what windows can be added on top of others.
like.
JFrame, JPanel, JMenuBar.
please if you can understand what i have said because I am not sure it makes sense the any help will be great.
thanks.
no ones replying ? is it a stupid question anything would help
Re: About layering JFrames JPanels and the whole deal with that?
I honestly don't know what you are asking. Are you looking for explanations like these?
Using Top-Level Containers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
A Visual Guide to Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)
Or are you looking for an explanation as to what can be added to what (Components are added to Containers - look at the inheritance of the classes you use)
Quote:
no ones replying ? is it a stupid question anything would help
Please don't expect unpaid volunteers to be online waiting to answer each and every thread 24/7
Re: About layering JFrames JPanels and the whole deal with that?
yes kind of so i was wondering if there was a specific order containers can be placed onto eachother. so like a jpanel cannot be placed on another jpanel. or is this still a stupid question?
Re: About layering JFrames JPanels and the whole deal with that?
My advice would be to try it and see...theory is one things, but getting it to work is another. Here's the theory:
Take a look at the inheritance hierarchy of JPanel
JPanel (Java Platform SE 6)
Component->Container->JComponent->JPanel
Now take a look at the add method in Container (which is what one uses to add things to a JPanel) - it is defined as accepting a Component ...in other words you can add anything that is a Component to a Container. JPanel extends both, so yes you can add one JPanel to another, just as you can add other JComponents to a JPanel. This nesting is powerful, as different JPanel's can have different LayoutManagers, allowing you a huge amount of flexibility in laying out a user interface.
And a note on your signature and comments - getting answers has everything to do with asking the question. See the link in my signature entitled 'getting help' as well as http://www.catb.org/~esr/faqs/smart-questions.html
Re: About layering JFrames JPanels and the whole deal with that?
thank you for your reply I will look into that.
very much appreciated.