Results 1 to 11 of 11
Thread: repaint method
- 04-21-2010, 03:47 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 4
- Rep Power
- 0
- 07-24-2010, 08:47 AM #2
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
Repaint() Error
Hey I m also facing the same problem ....You got some Solution to this.. if yes please post it immediately its urgent...
- 07-24-2010, 12:07 PM #3
Why do you want to call paint() directly?
YOu might want to if you have created your own Graphics object and want to paint it and then create an image from that to save to disk .
But if you want to update the GUI display, you call repaint() to tell the JVM to call your paint method with the correct graphics object and on the correct thread.
- 08-04-2010, 07:25 AM #4
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
@Norm
thanks for the reply. Sir m using two threads. one is system thread that is handling key events and another thread is its child thread created explicitly that is handling the graphics painting process. the child thread is used to call repaint method repeatedly after a particular period of time. for that i had used sleep(); declared inside a loop in the Run() method the entry point a thread.
Side by side the main thread handles the key events and paint() method draw the graphics accordingly.
now the issue is that i want to create a flashing effect on a particular line .. for that i had used a variable LINEDRAW....in paint() if LINEDRAW is 1 then it draws the line else not...
now in key event
following algo is defined:-
LINEDRAW=1;
Thread.sleep(100); // sleep the main thread that is handling the keyevents
LINEDRAW=0;
Thread.sleep(100); // sleep the main thread that is handling the keyevents
LINEDRAW=1;
Thread.sleep(100); // sleep the main thread that is handling the keyevents
the painting process should be handled parallely by the child thread created explicitly.
Now the flashing effects is seen only more delay in the painting process is seen..
...
I dont know y it is happening? Need serious help ... might be there may be the issue with the Threads... also tell me how to obtain reference to main Thread also how to know how many THREADS are running at a particular number of time in the program...
THANKS & REGARDSLast edited by nitin_daviet88; 08-04-2010 at 07:27 AM.
- 08-04-2010, 01:40 PM #5
YOU need to tell the GUI system that that the LINEDRAW variable has changed and that you want the GUI system to call the paint() method to do the drawing that the LINEDRAW variable requests.
You do that by calling the repaint() method. Some time later the GUI system will call the paint method to do the new drawing.
- 08-05-2010, 07:08 AM #6
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
yes sir i had done the same thing... actually repaint() statement is running in a loop it is called after every 1 second this is handled by the child i created.
sir once i stopped this loop and start calling paint() whenever required that too doesnt work.... i dont know y ?
LINEDRAW=1;
repaint();
Thread.sleep(100); // sleep the main thread that is handling the keyevents
LINEDRAW=0;
repaint();
Thread.sleep(100); // sleep the main thread that is handling the keyevents
LINEDRAW=1;
repaint();
Thread.sleep(100); // sleep the main thread that is handling the keyevents
this too doesnt work . then i used S.O.P. to check the Flow of the block....
LINEDRAW=1;
System.out.println("About to call Paint method");
repaint();
System.out.println("After calling paint method");
Thread.sleep(100); // sleep the main thread that is handling the keyevents
LINEDRAW=0;
System.out.println("About to call Paint method");
repaint();
System.out.println("After calling paint method");
Thread.sleep(100); // sleep the main thread that is handling the keyevents
LINEDRAW=1;
System.out.println("About to call Paint method");
repaint();
System.out.println("After calling paint method");
Thread.sleep(100); // sleep the main thread that is handling the keyevents
Inside the paint() there's a statement :-
System.out.println("Paint is called");
Now the following output was obtained:-
About to call Paint method
After calling paint method
About to call Paint method
After calling paint method
About to call Paint method
After calling paint method
No PAINT IS CALLED was found..
now it only leaves the inference that repaint() statement was not Implemented by the system.... Hope you got the problem.... Sir I need to Implement the flashing effect of line in the program.... that too Within 2 days.....
This JAVA programming is killing me.........
- 08-05-2010, 01:04 PM #7
Try putting:No PAINT IS CALLED was found.
@Override
before the paint method definition to make sure you are actually overriding the method. A spelling error or wrong args would create a new method vs overriding the paint method.
- 08-07-2010, 06:52 AM #8
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
Sir , M using NetBeans IDE for the development. It indicates that paint() is overridden by the my paint() defination...
it indicates multiple Annotations if i place @override statement before that......
Thanks & Regards
- 08-07-2010, 02:09 PM #9
Sorry, I don't know anything about your IDE and its warning/error messages.it indicates multiple Annotations
How many different classes do you have that you have overridden the paint() method in?
Are any of them called when you do a repaint()?
- 08-12-2010, 07:03 AM #10
Member
- Join Date
- Jul 2010
- Posts
- 7
- Rep Power
- 0
Sir
I need some help on Threads...
There are two threads A & B.
One Method--Gamepaint();
Both threads call the Gamepaint();;
the Array variables used in Gamepaint() are Initialized and set by Thread B at regular interval of time by calling another method SetFlash()... and simultaneously the Thread A accesses those variables by calling Gamepaint();
when this happens in a loop it generates an array_index_out_of_bound EXCEPTION
when run for one time it works well...
i want that Thread A should not access variables in gamepaint(); before it had been set by Thread B By calling setFlash();;;;
Hope you got the problem..
Thanks & Regards
- 08-12-2010, 03:12 PM #11
I'm not sure what that means.i want that Thread A should not access variables in gamepaint();
If the variables are local to the gamepaint() method, how can code in another method access them?
A thread doesn't have variables.
If you want different callers of a method to have/use their own data, put the data in an object and have each caller pass that object to the method.
Similar Threads
-
repaint every
By 3xpr1ment in forum AWT / SwingReplies: 10Last Post: 03-23-2010, 05:39 PM -
Trying to do a simple repaint
By IYIaster in forum New To JavaReplies: 9Last Post: 10-14-2009, 10:30 PM -
repaint problem
By amith in forum Java 2DReplies: 2Last Post: 07-01-2008, 12:10 AM -
Problem in repaint
By Preethi in forum AWT / SwingReplies: 16Last Post: 03-18-2008, 08:10 PM -
Repaint problem
By swimberl in forum Java 2DReplies: 0Last Post: 01-06-2008, 03:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks