*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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.
 
Don't get me started about those stupid light bulbs.
 
subject: JDesktopPane Graphics