This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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


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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: JDesktopPane Graphics
 
It's not a secret anymore!