Migrating Java Applet to Java WebStart (JNLP)

和自甴很熟 提交于 2019-12-04 20:33:45

An alternative containment for you application could be a JFrame.
A migration path would be refactoring (moving) the actuall UI Code into a JPanel. That one can be placed into the JApplet or for an Java WebStart application into a JFrame. (during that time you could have a hybrid application).

<!-- main in MyApplication -->
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                JFrame frame = new JFrame();
                frame.setTitle("MyApplication via JWS");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                // add here the real UI to the frame: setUpGUI(frame);
                frame.pack();
                frame.setVisible(true);
            }
        });
    }

<!-- Init() in MyApplication extends JApplet -->

    @Override
    public void init() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                // add here the real UI to the applet: setUpGUI(MyApplication.this);
            }
        });
    }

Note: the EventQueue.

According Question 1:
Some of the Applet specifica have to be replaced be different ways.
Find the basics here: https://docs.oracle.com/javase/9/deploy/jnlp-api-examples.htm
e.g.: for AppletContext there is the BasicService as some kind of replacement.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!