Resizing an Applet which was started with Java Webstart as Standalone

Veröffentlicht: Mai 14, 2010 in Java
Schlagwörter:, , ,

I’m playing around with the Features of the latest Java Plugin for Browsers.
I just can say, you should really use the JavaScript one, to create Applet- or Webstart-Tags.

Due this new features I decided to deploy my applet with Java Webstart and created a JNLP file. Works like a charm.

But after I started my applet in Standalone Mode with my created Desktop-Icon, I couldn’t resize my applications. Normally you would call the Methode „setResizable“, but JApplet doesn’t provide one.

So here is the Solution I found for this problem without developing an Extra Class to launch my Applet as an Application.

Solution -> extend the JApplet.init() Method:

Window window = SwingUtilities.windowForComponent(this);
if (window instanceof JFrame){
JFrame frame = (JFrame)window;
if (!frame.isResizable()){
frame.setResizable(true);
}
}

Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s