Splash Screen?

Hello,

I have been searching in the forum something that can help me make splash screen for my application. I found only post about how to make splash screen during the loading of the application. Is it possible to make one which stays until you press button to load the application?

Thank you!
BR,
Elena

Hi Elena,

You probably already read this Wiki article, where the customized loading indicator is used as a splash screen: https://vaadin.com/wiki/-/wiki/Main/Adding+a+splash+screen

As the loading indicator is removed when the application is loaded, the splashing screen will disappear too. To simulate “sticky” splashing screen, you can try to add a Label, which is themed to look excatly like the splashing screen in your UI. If you add the label as a first step of your UI initialization, it should look like if splashing screen stays after the loading is complete. To remove it you can add a button to your UI which removes the labels and shows the first view of your application.

There might also be more sophisticated ways to do this, but this was the first idea that came into my mind.

Br. Johannes

Thank you so much Johannes!

That is what i did:

  1. Created SplashScreen Class

[code]
public class SplashScreen extends JWindow {

private int duration;

public SplashScreen(int d) {
    duration = d;
}

// A simple little method to show a title screen in the center
// of the screen for the amount of time given in the constructor
public void showSplash() {
    
    JPanel content = (JPanel)getContentPane();
    content.setBackground(Color.white);
    
    // Set the window's bounds, centering the window
    int width = 450;
    int height =115;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width-width)/2;
    int y = (screen.height-height)/2;
    setBounds(x,y,width,height);
    
    // Build the splash screen
    JLabel label = new JLabel(new ImageIcon("..\\background.png"));
    
    content.add(label, BorderLayout.CENTER);
    Color oraRed = new Color(156, 20, 20,  255);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));
    
    setVisible(true);
    try { Thread.sleep(duration); } catch (Exception e) {}
    
    setVisible(false);
    
}

}
[/code]2. Added the splashscreen object in init

  SplashScreen splash = new SplashScreen(10000);
        splash.showSplash();

It is loading for while but it doesn’t show the image. After while it load the application.
How i can make it work?

Thank you!

BR,

Hmm. So you are not implementing a
Vaadin nor web application
, but standard desktop java app? If this is the case, I think you will find better instructions for that from the other places than Vaadin forum. See e.g. this article:
http://www.javaworld.com/article/2077467/core-java/java-tip-104–make-a-splash-with-swing.html

I actually used a notification and background image. So much easier :slight_smile:

Notification notif = new Notification( "", "", Notification.TYPE_HUMANIZED_MESSAGE); notif.setDelayMsec(20000); notif.setStyleName("mystyle"); notif.show(Page.getCurrent()); And then just added background image.

It works good for me.

BR,
Elena