• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using mouse clicks to draw on a JFrame, problem probably with coordinates

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having problems drawing a rectangle, circle, and a straight line of a JFrame. I'm pretty sure I'm getting my coordinates off and I've spent hours trying to fix it which usually leads me to messing it up even more. If I somewhat fix one part of it, it just ends up messing up another part, so if anyone could help me out and show me what I am messing up it would be very much appreciated. The polygon part can be ignored, I will work on it once I get my coordinates fixed. Sorry if its a little long, I didn't know if I needed to attach all or just the part I'm having problems with so I went with the first. Thanks again.


 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never use getGraphics of a Component, and don't perform custom painting in a top level window but rather in a JPanel or JComponent that is then added to the window.
 
michael perkins
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:Never use getGraphics of a Component, and don't perform custom painting in a top level window but rather in a JPanel or JComponent that is then added to the window.



I know I needed a JPanel to do the painting on, but believe it or not that was the way my teacher recommended so I left out the extra work. I wish I had a teacher that knew java, but I've asked her many questions and she hasn't been able to answer any of them. I asked her the question I asked here before I posted it here and she couldn't help me. But thanks for pointing that out, I wish I had a more formal exposure but there's not much I can do about it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic