Results 1 to 5 of 5
Thread: repaint method called twice?
- 02-09-2013, 03:53 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
repaint method called twice?
Hello people,
why is repaint method called twice? i have searched online for the answer and i found this:
paint() in java applet is called twice for no reason - Stack Overflow
person who suggested the anwer said that there should be JPanel in the interface? should there be a jpanel if im going to make some game that will use g.drawImage method?
my source code is very similar to the code that i found in that example online. So that are my two questions. Why repaint is called twice, and should applet have jpanel in it or is it ok to draw graphics directly to japplet.
Thank you in advance in solving my dilema :) i have java experience but i have never used applets so i would need some guide.
- 02-09-2013, 03:56 PM #2
Re: repaint method called twice?
You have absolutely no control over how many times or how frequently painting methods are called.
Maybe you would like to go through Painting in AWT and Swing
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-09-2013, 04:02 PM #3
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
Re: repaint method called twice?
DarrylBurke thanks for reply, i will check it out definitely. That will mean that i will have to change logic of my code, and that i have thought in wrong direction, if i can't control how many time paint method is called.
-
Re: repaint method called twice?
- 02-09-2013, 04:58 PM #5
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
Re: repaint method called twice?
First thing that came on my mind is to limit system called -> uncontroled paint method triggering, with simple boolean expression. If (painted) {..}. And if i click on button to envoke app triggered painting. For example set painted variable to false and repaint(); Something like that but its rought taught i will have to consider other ways of doing that. Anyways thanks for the kind words Fubarable. When i code something i try to think on all aspects of my program. But thre most important are performance of the software, correct configuration and operability, and security. And as far as i managed to notice, painting methonds within java can have great influence on performance so they should be used carefuly. By the way, this is my little project i started working on yesterday https://www.youtube.com/watch?v=CV7blshTyUI
Last edited by rajke88; 02-09-2013 at 05:02 PM.
Similar Threads
-
Why does it seem this method isn't being called?
By Appel in forum New To JavaReplies: 7Last Post: 05-03-2012, 09:53 AM -
panel wont update when repaint is called
By yemista in forum AWT / SwingReplies: 3Last Post: 10-25-2011, 06:58 PM -
Paint(Graphics g) method is not called on its run.
By vsanandan in forum Java 2DReplies: 5Last Post: 10-22-2010, 01:55 PM -
while running multiple thread repaint isnt being called....
By raptor in forum Threads and SynchronizationReplies: 4Last Post: 08-25-2010, 11:47 PM -
repaint method
By manojp476 in forum CLDC and MIDPReplies: 10Last Post: 08-12-2010, 03:12 PM


LinkBack URL
About LinkBacks


Bookmarks