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

Drawing on JFrame

 
ajay smith
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple question: how do you draw stuff on a JFrame?
 
Tony Docherty
Bartender
Pie
Posts: 2878
59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple question: how do you draw stuff on a JFrame?

Simple answer: you don't

What you need to do is create a component that extends JComponent or JPanel to add to your JFrame and draw on that by overriding the paintComponent() method.
I suggest you read the following tutorials: http://docs.oracle.com/javase/tutorial/uiswing/painting/ and http://docs.oracle.com/javase/tutorial/2d/

 
Campbell Ritchie
Sheriff
Pie
Posts: 47292
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion would fit better in our GUIs forum: moving.
 
ajay smith
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
Simple question: how do you draw stuff on a JFrame?


What you need to do is create a component that extends JComponent or JPanel to add to your JFrame and draw on that by overriding the paintComponent() method.



Does that mean instead of extends JFrame I do extends JPanel or extends JComponent? Very confused
 
Rob Camick
Ranch Hand
Posts: 2475
8
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the tutorial!!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic