How to make full screen java applets?

前端 未结 4 1487
情话喂你
情话喂你 2021-02-20 04:59

I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this.

Since I

4条回答
  •  醉话见心
    2021-02-20 05:34

    Why not just open a new Frame from the applet (either from the "start()" method or, preferably, after the user presses an "open" button) and set it to be maximized?

    JFrame frame = new JFrame();
    //more initialization code here
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setSize(dim.width, dim.height);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    

    Don't forget: The JFrame should be created and opened from the EDT. Applet start() is not guaranteed to be called on that thread, so use SwingUtilities.invokeLater(). Of course, if you opt for the button route, button listener is called on the EDT, so you should be safe.

提交回复
热议问题