This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Graphics inside Frame  RSS feed

 
ajithsasi kumar
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir is it possible to use Graphics class inside Frame. My aim is to draw lines,polygon etc.. in Frame as if it where drawn in Applet using paint(Graphics g) method. Help me sir, thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd need to add a component that extends Panel to the Frame. Then you can perform any drawing you wish inside of the panel's paint method.
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside paintComponent that is:
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Swing it'd be paintComponent, but for AWT it would be paint. I'm assuming we're talking about AWT, since the post mentions Frame and paint, which are AWT classes/methods. Maybe we can get clarification on this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!