wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Drawing on JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Drawing on JFrame" Watch "Drawing on JFrame" New topic
Author

Drawing on JFrame

ajay smith
Greenhorn

Joined: Feb 02, 2013
Posts: 9
Simple question: how do you draw stuff on a JFrame?
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2165
    
  47
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

Joined: Oct 13, 2005
Posts: 37907
    
  22
I think this discussion would fit better in our GUIs forum: moving.
ajay smith
Greenhorn

Joined: Feb 02, 2013
Posts: 9
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

Joined: Jun 13, 2009
Posts: 2152
    
    7
Read the tutorial!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drawing on JFrame
 
Similar Threads
NetBeans IDE 5.5
why no default close button in JDialog
how to invoke FileDialog from a dialog?
How to display JFrame with orientation Right_To_Left in Windows 7 64bit..?
painting problems