• 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:

Simple JPanel question

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,
I am taking a beginning course in Java. I am working on a simple program to draw circles. I have to create a JFrame and embed a JPanel into the JFrame. I am not sure if I have this set up properly, but when I run the program nothing appears in the JPanel. I just need some help getting the circle to appear in the JPanel. Here is my code:


Any help is appreciated. Thanks.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rebecca, and welcome to the Ranch! Whenever you post here, please use the code tags -- highlight your code and click the Code button above the editing area. Since you're new here, I've added the tags for you and you can see how much more readable the code is now.

You have a CirclesPanel class that isn't used in the GUI, where you add a simple JPanel with its background set to WHITE. That isn't going to automagically run the painting code in your custom class -- to use that, you have to actually construct an instance of the class and display it in the GUI.
 
Rebecca Weber
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:Hi Rebecca, and welcome to the Ranch! Whenever you post here, please use the code tags -- highlight your code and click the Code button above the editing area. Since you're new here, I've added the tags for you and you can see how much more readable the code is now.

You have a CirclesPanel class that isn't used in the GUI, where you add a simple JPanel with its background set to WHITE. That isn't going to automagically run the painting code in your custom class -- to use that, you have to actually construct an instance of the class and display it in the GUI.





Darryl,

Thank you for the advice. I apologize about the code tags, I will remember for next time.
Rebecca
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic