This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JDesktopPane Graphics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDesktopPane Graphics" Watch "JDesktopPane Graphics" New topic
Author

JDesktopPane Graphics

roger denton
Greenhorn

Joined: May 03, 2003
Posts: 5
I would like to draw graphics (lines, rects, and such) in a JDesktopPane. Below is a snippet of code...
desktop = new JDesktopPane();
Graphics g = desktop.getGraphics();
System.out.println("g = " + g);
g.drawLine(x,y,xend,yend);
g is null and drawLine dies as you might expect (null pointer exception).
So, my question is, is it possible to draw directly in a JDesktopPane? If so, how?
Thanks,
Roger
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I don't know too much about Swing but this program draws the line.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
roger denton
Greenhorn

Joined: May 03, 2003
Posts: 5
Barry,
Thanks...I had the order wrong with setVisible.
Many thanks.
Roger
Originally posted by Barry Gaunt:
I don't know too much about Swing but this program draws the line.
 
jQuery in Action, 2nd edition
 
subject: JDesktopPane Graphics
 
Similar Threads
simple graphics question
Flickering of Canvas
Painting to a specific component
Multiline JLabel
can you resolve these questions?Thanks.