Search code examples
javaappletjnlpjava-web-start

Make a JNLP Web-Start applet resizable


We have an applet used to run our app in-browser, but we also provide a JNLP web-start option. When the web-start window launches, it is not resizable or maximizable and we want to make this possible.

I initially thought it be a simple setting in the JNLP file but now I'm not sure. How should I be approaching this?


Solution

  • There is no setting in the JNLP that caters for a resizable applet viewer (which is what JWS uses to show floating applets).

    OTOH a little bit of hackery might get you there. I can recall doing this some (long) time ago. I think from memory it basically involved getParent() in a loop until null, the last component before that was a JFrame. Once you have a reference to the frame, you can call setResizable(true).

    In fact, (considers) you might also look into JComponent.getTopLevelAncestor() for getting a reference to the root frame. AFIU that method did not exist when I tried the experiment. (Yes, it was that long ago.)

    Of course, an overall better strategy is to create a hybrid application/applet. Embed the applet into a browser, and launch the frame by JWS. This provides full control over the GUI.