Regarding JPanel and JFrame
I am trying to design a simple game using Java, and i just was wondering if someone could please explain to me if my process of going about it regarding panels and frames is right or now.
Now I am going to have one frame, the main frame, where everything will be drawn on top of, and then multiple panels. For example if the user is playing then they are on a certain panel, but for example if they pause the game, or want to go to another screen, i can hide the panel and show the other one.
Now does this make sense, or am I thinking of it all wrong. The problem was that I started to code the program, and I was just beating my head, because I was having a hard time of figuring how I would set it up. I just wanted to know what people thought or if they had a link to something like this, or any ideas of their own.
Thank You for all your help.
[873 byte] By [
Karan13a] at [2007-10-2 4:47:46]

> Now I am going to have one frame, the main frame,
> where everything will be drawn on top of, and then
> multiple panels. For example if the user is playing
> then they are on a certain panel, but for example if
> they pause the game, or want to go to another screen,
> i can hide the panel and show the other one.
That approach will work and be reasonably neat. You might want to have a look at CardLayout though.
Drake
Thank you for the replies. I looked over the cardlayout and it does look interesting and i will look into it. I have just been having problems with for example having multiple panels and assigning labels to different panels. Any ideas. I know the forums are all linked with this stuff, but I wasn't sure if you suggested any place, because I have seen some of the places, and I am looking on my own at other issues, like panels being able to display background images. But i am just having the silly problem where I can't seem to add components to labels to panels, when i have more than one assigned.
Hope that makes sense
> background images. But i am just having the silly
> problem where I can't seem to add components to
> labels to panels, when i have more than one
> assigned.
>
> Hope that makes sense
It sounds like you just mean losing track of things when viewing your .java file. If that is the case then maybe you are writting ugly code. You could post some and people could tell you in pretty much a single glance whether it was readable or not.
Drake