• Post Reply Bookmark Topic Watch Topic
  • New Topic

trying to do a nested circle dynamically

 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i want to draw a circle inside a circle in java. can any one help me or tell me the step to follow to be able to do it. thank you
so far i'm using this piece of code
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Custom painting is done by overriding the paintComponent() method of a JPanel. Read the section from the Swing tutorial on Custom Painting for more information and examples.

Start by painting one circle. Once that is working you try painting a second circle.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank for your reply. i'm able to draw the big circle. i don't know how to proceed to have a smaller one inside the big circle.


with this code i draw the bigger circle. it call this method
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE demonstrating the problem.

I don't see the problem. If you can draw one circle you can draw a second circle. Just make sure you draw the large circle first.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm doing this


but it does not draw the 2 circle and i don't know why. graphSetting is where i set my stroke etc.
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not a SSCCE.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SSCCE is my full code, but i remove everything that is not relevant to the problem?? i am right?
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nathalie Monvoisin wrote:The SSCCE is my full code, but i remove everything that is not relevant to the problem?? i am right?


No, it's a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
 
Nathalie Monvoisin
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please give me an example of a SSCCE
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the SwingPaintDemo2 code found in the example index of the Swing tutorial on Custom Painting.

Your question is about painting. So the demo is a complete application with simple painting.

The main difference would be that you replace the code that draws the String with your code that draws the two circles.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!