Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDesktopPane Graphics

 
roger denton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know too much about Swing but this program draws the line.
 
roger denton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic