Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Display a drawing created in a different class.  RSS feed

 
Edward Spencer Spencer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a class that draws a polygon and other items attached to the polygon -the drawing displays fine. I then created another class with a panel and instantiated the polygon object in it. How do I now display polygon object so that is shows in this panel?

Three classes:

Polygon.java
Created a polygon object that displays in a Graphics page
PolygonPanel.java
Created a panel and instantiated the object
PolygonAnimate .java
Here I set up my JFrame and added the ShapePanel.

Thank you
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have the JPaenel, just override the paintComponent and use the Graphics object to render your Polygon.

g.drawPolygon(); or g.fillPonlygon();

 
Edward Spencer Spencer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply. I just figuredit out



Thanks for the help
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not familiar with that, to what are you adding the polygon?

Edward Spencer Spencer wrote:thanks for the reply. I just figuredit out



Thanks for the help
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!