File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDesktopPane Graphics