Java SplashScreen in Java Web Start

I am trying to port a Java Swing project to Java Web Start and I have a problem with the splash screen. This app uses Maven.

When I download my application through the command line or an external exe, it correctly displays the splash screen.

final SplashScreen splash = SplashScreen.getSplashScreen();

When I launch the application through Java Web Start, it always returns null.

Yes, I know about the splash screen section in the JNLP file.

<icon kind="splash" href="splash.png"/>

But this will show a splash screen before downloading the application, and not when the application is running. In other words, this is not a switch replacement --splash.

In the manifest file, I:

   SplashScreen-Image: (URL to resource,  file in jar)

This only works well when running a jar file, and not in Java Web Start.

- - ? , , .

+3
3

JNLP-, start(), . , stop().

public class ShowSplash 
{
   private static JWindow splashFrame;

   public void start(String splashImagePath) throws Exception
   {
      JLabel label;
      ImageIcon image;
      URL url;

      splashFrame = new JWindow();
      url         = ShowSplash.class.getResource(splashImagePath);
      image       = new ImageIcon(url);
      label       = new JLabel(image);

      splashFrame.add(label, BorderLayout.CENTER);
      splashFrame.pack();
      splashFrame.setLocationRelativeTo(null);
      splashFrame.setVisible(true);
   }

   public void stop() throws Exception
   {
      splashFrame.dispose();

      splashFrame = null;
   }
}
+2

JWS ( ) SplashScreen AWT. JWS , JNLP. JNLP.

+1

, SplashRenderer JWindow.

:

    splashFrame = new JWindow();

    splashFrame.setBackground(Color.white);

    JPanel splashPanel = new JPanel();

    splashPanel.setLayout(new BorderLayout());

    JLabel image = new JLabel(img);

    splashPanel.add(image); 

    splashFrame.setContentPane(splashPanel);
    splashFrame.pack();
    splashFrame.setLocationRelativeTo(null);
    splashFrame.setAlwaysOnTop(true);
    splashPanel.paintImmediately(0, 0, splashPanel.getSize().width, splashPanel.getSize().height);
    splashFrame.setSize(splashPanel.getSize().width,splashPanel.getSize().height);
    splashFrame.setLocation(100, 100);
    splashFrame.setVisible(true);

The window is always in the opposite direction, it does not matter if I set setAlwyasOnTop or set these methods in the background thread. SplashRender in this case always remains at the top, but JWindow is not.

Currently valid - When I launch APP, the window does not appear at startup, but it shows when MainFrame is displayed.

0
source

All Articles