Two Laptop Bag*
The moose likes Swing / AWT / SWT and the fly likes Adding a new page to my contaier. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding a new page to my contaier." Watch "Adding a new page to my contaier." New topic
Author

Adding a new page to my contaier.

david weatherholt
Greenhorn

Joined: May 03, 2012
Posts: 3
I am trying to add a page I created, called "CenterPanel.java" to the CENTER position of my containter page. (IntroPanel.Java)



Here is my MAIN.



Here is my containter.. this is where I would like to add CenterPanel.Java into the CENTER position of my borderlayout



THIS is the page I am trying to add into my "IntroPanel.java" BorderLayout.CENTER position.



















Bonus page, PizzaPanel.Java.. I am trying to add this to a tab on my CenterPanel.java page.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
add (centerpanel, BorderLayout.CENTER); ///////////////// HELP ME HERE???

if centerpanel is an instance of the class CenterPanel, you can't.

CenterPanel is a JFrame, so it cannot be added to a container.
You'll have to change anything to do with frames to JPanels
david weatherholt
Greenhorn

Joined: May 03, 2012
Posts: 3
Is there any way I can make my CenterPanel have a set of tabbed panels inside of it? Even though I want to add it to my IntroPanel.java's BorderLayout.CENTER?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Make CenterPanel a JPanel and add a JTabbedPane to it.
david weatherholt
Greenhorn

Joined: May 03, 2012
Posts: 3
Thank you very much for the reply's!

I am receiving a run time error message
Exception in thread "main" java.lang.IllegalArgumentException: adding a window t
o a container
at java.awt.Container.checkNotAWindow(Container.java:483)
at java.awt.Container.addImpl(Container.java:1084)
at java.awt.Container.add(Container.java:966)
at IntroPanel.<init>(IntroPanel.java:44)
at PizzaLab.main(PizzaLab.java:25)
Press any key to continue . . .



I believe my CenterPanel.java code is messed up... I am trying to add tabs to my other pages, PizzaPanel and DrinksPanel.

Here is my CenteraPanel.java code..


(Code commented off , not using it, just there playing with it... trying to figure it out)
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
in my first reply I had this
"CenterPanel is a JFrame"

nothing has changed
"public class CenterPanel extends JFrame "
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding a new page to my contaier.
 
Similar Threads
JComboBox problem...
missing components
Help i need help with borderlayout
JScrollpane problem
HELLP! i cant get 2 JPanels to display without them sitting on the other!