• 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

drawstring on canvas

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seven buttons. Each button draws a different string. In my actionlistener method, I first call repaint to clear the canvas, then I draw the string. Unfortunatly, after clearing the canvas, the new text is drawn, then repainted again. Any solutions?
thanks,
dennis
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some code would help.
 
Dennis Riggs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Cindy,
Here is the paint method:

The system.out is for my troubleshooting. If you have a clue, I'd appreciate some help.
thanks,
dennis
(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited March 26, 2001).]
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try reading this painting tutorial: http://java.sun.com/docs/books/tutorial/uiswing/overview/draw.html
[This message has been edited by Cindy Glass (edited March 26, 2001).]
 
Dennis Riggs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip. Although the link refers to swing, does the Opaque also work for AWT?
thanks,
dennis
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the AWT components get their opaque window from the native window.
This is a rather old article disussing how to turn heavyweight AWT components into lightweight components - which is exactly what Swing does for you: http://java.sun.com/products//jdk/1.2/docs/guide/awt/designspec/lightweights.html
 
Dennis Riggs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may consider me dense if you like. It seems maybe I haven't communicated my problem very well, or Java is much more verbose than I thought it was. When I run my code above, the expected system.out should be 1st: "I'm at Paint" then second, "I'm at btn 2" however just the oppisite occurs. In order to get around this, do I truely need to worry about Opaque, and lightweight controls? Or is there something I can do with my present code to solve the problem that Paint is actually called before my drawstring instead of after? thanks with your patience.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I though that they were two separate questions.
I would think that calling repaint inside paint would cause a problem, however let's move this to AWT/Swing and see if you get some better suggestions.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic