This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Simple JPanel question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Simple JPanel question" Watch "Simple JPanel question" New topic
Author

Simple JPanel question

Rebecca Weber
Greenhorn

Joined: Apr 06, 2011
Posts: 3
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

Joined: May 03, 2008
Posts: 4571
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Rebecca Weber
Greenhorn

Joined: Apr 06, 2011
Posts: 3
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
 
GeeCON Prague 2014
 
subject: Simple JPanel question