Applet: repaint() won't call update()/paint()

25 views
Skip to first unread message

Ferdinand Zeppelin

unread,
Jun 24, 2019, 1:37:00 PM6/24/19
to AjaxSwing Community Support
Hi,
I'm trying to make an old Java game (from around 2001) playable through the browser.
However the game appears to be frozen. The repaint() method doesn't call paint() at all.

Server OS: Tomcat
AjaxSwing version: 4.6.1
JDK version: 1.8.0_171

Here's a TestApp for reproducing the condition:

import java.applet.Applet;
import java.awt.Font;
import java.awt.Graphics;
import java.util.Date;

public class TestApplet extends Applet implements Runnable {

    Font theFont = new Font("Arial", Font.BOLD, 12);
    Date theDate;
    Thread runner;

    public void start() {
        if (runner == null) {
            runner = new Thread(this);
            runner.start();
        }
    }

    public void stop() {
        if (runner != null) {
            runner.stop();
            runner = null;
        }
    }

    public void run() {
        while (true) {
            theDate = new Date();
            System.out.println("repaint()");
            repaint();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) { }
        }
    }

    public void paint(Graphics g) {
        System.out.println("paint()");
        g.setFont(theFont);
        g.drawString(theDate.toString(), 10, 50);
    }
}

Yevhen Badorov

unread,
Jun 25, 2019, 5:51:27 AM6/25/19
to AjaxSwing Community Support
Hi!
Thank you for your message. We will check this issue and give you a response as soon as possible! 

Best regards, Ajaxswing team

Yevhen Badorov

unread,
Jul 3, 2019, 3:49:59 AM7/3/19
to AjaxSwing Community Support
Hi!
I've checked your code in AjaxSwing and everything works as expected. The paint method is called first and then repaint.
Could you please send me configuration for your app for AjaxSwing you're using?


On Monday, June 24, 2019 at 8:37:00 PM UTC+3, Ferdinand Zeppelin wrote:

Ferdinand Zeppelin

unread,
Jul 30, 2019, 3:26:24 PM7/30/19
to AjaxSwing Community Support
Hello again,
so when you run it, the seconds are getting updated?
For me, paint() is only called when I interact with the website (e.g. click on it, type something on the keyboard, resize the window).
repaint() however is called every second.

Here's my properties file:

#AjaxSwing properties file
#Tue Jul 30 21:12:09 CEST 2019
agent.appStartClass=TestApplet
agent.classPath=C\:\\Users\\MyName\\workspace\\TestApplet\\bin/
applet.documentBase=http\://localhost\:8040/ajaxswing/testapp/

Yevhen Badorov

unread,
Jul 31, 2019, 4:29:31 AM7/31/19
to AjaxSwing Community Support
Hello Ferdinand,

Try to play with the following property in conf\default.properties :
window.*.autoRefresh

It will force the page to refresh its state with a specified interval.

Best regards, Ajaxswing team

Ferdinand Zeppelin

unread,
Aug 2, 2019, 1:03:06 PM8/2/19
to AjaxSwing Community Support
Hi,
thanks for your answer!

It kind of works for the test applet but unfortunately the actual applet (the Java game from 2001) should run at around 30 FPS.

Yevhen Badorov

unread,
Aug 6, 2019, 5:18:20 AM8/6/19
to AjaxSwing Community Support
Hi Ferdinand,

Thanks for your message!
AjaxSwing currently doesn't support the ability to run apps at a frame rate that you need.
Please let me know if you have any other questions.

Best regards,
AjaxSwing team
Reply all
Reply to author
Forward
0 new messages