Adding jpanels to existing frame

View: New views
3 Messages — Rating Filter:   Alert me  

Adding jpanels to existing frame

by cbyron2003 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all.
Just looking for some advice regarding a UI i am producing using netbeans. Not sure if this is neing posted in correct area so if not either move it or let me know and i will repost elsewhere.
I have a jframe  which consists of a jpanel and a button. I also have a seperate class which produces another jPanel. When the button is clicked in the original jframe i want to replace the first jpanel with the second. I had thought that when the button was clicked I could simply do a 1stPanel.add(2ndPanel) and then a repaint() but this is not working.
I think that something needs to change in the layout manager but as netbeans creates this I am not sure how or what to change.
I will eventually have several classes all creating independent Jpanels and I would like to add these to my original frame as and when i require them so any help or ideas and hw this might be done would be greatly appreciated.

Thanks

Re: Adding jpanels to existing frame

by Katebe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi cbyron2003, I have exactly the same problem you have, and I couldn't find anything on the net. Please if you find the solution, tell me how you did. Of course I'll do the same thing if I got it before you. thanks

Re: Adding jpanels to existing frame

by JosiahHaswell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Katebe wrote:

>
>     Hi cbyron2003, I have exactly the same problem you have, and I
>     couldn't find anything on the net. Please if you find the
>     solution, tell me how you did. Of course I'll do the same thing if
>     I got it before you. thanks
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: Adding jpanels to existing frame
> <http://www.nabble.com/Adding-jpanels-to-existing-frame-tp15243300p15324289.html>
> Sent from the Netbeans - UI mailing list archive
> <http://www.nabble.com/Netbeans---UI-f2608.html> at Nabble.com.
Check out CardLayout, or consider if a Wizard might be suitable for the
task.

Joe