This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

HELLP! i cant get 2 JPanels to display without them sitting on the other!

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically the error I get is, "Do not use A3PizzaProgram.add() use A3PizzaProgram.getContentPane().add() instead"
I thought i was meant to use setContentPane("panelname") in the class for it to show up? And if I dont use two classes, and I put them in one, i cant get the 2 panels to show next to each other. They kind of sit on top of the other. I know its something to do with the "setContentPane()"
This is not all of the code but the code where I am using the Swing stuff.

.....

Also how can I incorporate this thread code
It dont seem to work, with two classes. i know there is a work around.
[ March 30, 2004: Message edited by: Karis Brown ]
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the "A3PizzaProgram" class? I don't see it anywhere in the code you posted...
 
Karis Brown
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It goes in the begining...here u go
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just like JFrame, JApplet is a top-level component, so you have to add things to the content pane instead of directly to the applet itself.

In the init() method of A3PizzaProgram you should have something like this (you may want to change the layout around a bit though... GridLayout just lines components up giving each one equal space):

 
Karis Brown
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
would i have to do the same getContentPane for all my stuff in my other classes?
 
Karis Brown
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is driving me nutz! i got to hand this in today!
why is the pSc class not wshowing up on the screen applet, only the stuff in the public class A3Pizza shows. and my pIc will not compile anymore since this getContentPane thing.
 
Karis Brown
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please all help would be grateful for!, cant get my head roud why this cant compile let alone work!
my pIc class wont compile and my pSc does not even appear.
 
Karis Brown
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dont worry about it, i decided not to do it in two seperate classes, makes things to complicated, however it would have made my calculations more easier and less coding.
 
reply
    Bookmark Topic Watch Topic
  • New Topic