aspose file tools
The moose likes Applets and the fly likes Need a Solution Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Need a Solution" Watch "Need a Solution" New topic
Author

Need a Solution

Sarah Haideri
Greenhorn

Joined: Jun 22, 2001
Posts: 28
I have an old applet which loads image. What can be done to increase the refresh rate? I know it contains some deprecated methods of Thread class. What can be done to stop using those methods?
Here is source code. Can someone update it to increase the refresh rate and get rid of the deprecated methods?
Thanks.
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
Sarah if you want a better response, maybe you should try posting this in the Applet or one of the Java In General forums As this forum is only related to questions on the SCJP Exam


<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Right, I'm moving this to the Applet forum.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Gee I'd like to help, but I don't know to which of the FIVE forums in which you posted this exact same question I should respond. :roll:
[ February 26, 2002: Message edited by: Rob Ross ]

Rob
SCJP 1.4
Sarah Haideri
Greenhorn

Joined: Jun 22, 2001
Posts: 28
Why don't you reply here if you know?
Thanks.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
As to increasing the refresh rate, why don't you not sleep for a second in your loop? that seems like it would certainly speed things up.
As for suspend/resume, well you can just stop using them. If you want to get the same effect in your thread, you could add a global variable to the class like "sleep", and set this to true when your applet gets a stop() event. In your image thread, you can check for this boolean in your loop and when it's true, you call sleep(0); that will have the same effect as suspend(). Then in your start() method, you can call interrupt() on the image thread, which will wake it up, similar to resume.
Another way to design this is to have an image thread just continuously get the image and save it to a buffer, then set a global boolean to true, and another repaint thread that continuously checks this boolean, and when it's true:
1. sets it to false
2. copies the buffer to your image area and calls repaint. That way the image is only refreshed when there is a new image to paint.
[ February 26, 2002: Message edited by: Rob Ross ]
Sarah Haideri
Greenhorn

Joined: Jun 22, 2001
Posts: 28
Thanks Rob for the reply. Can you please change the code so that it does what you are suggesting?
Thanks a lot.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
No, sorry. You should be able to do it yourself though with the information I have given you.
Good luck!
[ February 26, 2002: Message edited by: Rob Ross ]
 
I agree. Here's the link: jrebel
 
subject: Need a Solution
 
Similar Threads
Simple Thread with image..
A question
Creating Java applet
A question
drawImage not getting the image drawn before printing!