This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 1946
    
  28
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: 36556
    
  16
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: 2093
    
    7
Read the tutorial!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drawing on JFrame
 
Similar Threads
how to invoke FileDialog from a dialog?
NetBeans IDE 5.5
why no default close button in JDialog
How to display JFrame with orientation Right_To_Left in Windows 7 64bit..?
painting problems