File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple JPanel question

 
Rebecca Weber
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic