The Artima Developer Community
Sponsored Link

Java Answers Forum
query about paint() method in graphics

1 reply on 1 page. Most recent reply: Apr 4, 2002 7:46 PM by steve strongheart

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Aarti

Posts: 6
Nickname: aarti
Registered: Apr, 2002

query about paint() method in graphics Posted: Apr 3, 2002 10:14 AM
Reply to this message Reply
Advertisement
I have implemented a paint method in a awt frame.i have a big application and the class with the paint is called in the middle of the execution. the paint method has a for loop and takes some time to execute.the code works fine by itself.but when i integrate the code in the big apllication it fails to enter the paint method and the entire execution is disrupated and the system hangs. Even if I make a call to the paint() explicitly by repaint() it does not execute.I tried to implement paint as a separate thread but no use.i really dont understand. One thing i was thinking is that the frame.show() returns before paint() can complete execution.Does this mean that the execution never enters paint().is it invoked when a call to the class is made?

please help me


steve strongheart

Posts: 12
Nickname: stronghear
Registered: Apr, 2002

Re: query about paint() method in graphics Posted: Apr 4, 2002 7:46 PM
Reply to this message Reply
painting tips :

repaint() does not garauntee any action whatsoever, like calling a painter, he'll come, eventually.

graphics routines should be streamlined - try to separate rendering and calculating as much as possible.

do as much graphics work offscreen as you can.

use g.clip(Spape /*Rectangle usually*/ )to reduce the amount of area that has to be painted.

in Java2 swing classes, override paintComponent(Graphics g)instead of paint(g), or be sure to call super.paint(g) to be sure handle important graphics maintainence.

get lots of books and docs.

good luck
~S~

Flat View: This topic has 1 reply on 1 page
Topic: file attachment Previous Topic   Next Topic Topic: Synchronization and collections

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use