Question: I have created a simple splash screen that is basically a `JFrame` with a background image, two `JLabels` and a `JProgressbar`. When I only render the frame with the background image it takes about 200 milliseconds which is a good time for the splash screen.

But as soon as I add a JLabel (using Sansserif-font) it takes two seconds! So creating a string is 9 times as time intense as rendering an image.

How can I reduce the rendering speed of the JLabels or of the panel?

```
private static final Dimension LOADINGSCREEN_DIMENSION = new Dimension(400, 400);

private LoadingScreen() {
    super();
    this.setUndecorated(true);
    this.setResizable(false);
    this.setLayout(new BorderLayout(0, 0));
    this.setSize(LOADINGSCREEN_DIMENSION);
    this.setPreferredSize(LOADINGSCREEN_DIMENSION);
    this.setContentPane(createContentPane());

    //UNCOMMENT THIS LINE and it will take about 2 seconds to create
    //this.add(createInformationLabel(), BorderLayout.SOUTH);

    //Set location and pack
    final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
}

private JLabel createInformationLabel() {
    JLabel infoLabel = new JLabel("Label");
    infoLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));
    infoLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    infoLabel.setBorder(new EmptyBorder(50, 0, 10, 20));
    infoLabel.setOpaque(false);
    return infoLabel;
}

```

Answer: 
This has nothing to do with rendering speed. The rendering speed of all that is in the order of tens of milliseconds. 

The performance penalty you are witnessing has to do with loading classes. Before a `JFrame` can be rendered, its class needs to be loaded, and all classes that it depends on, and so on, and so forth. Then you are instantiating a `JLabel`. This class needs to be loaded, and all the classes that it depends on. Then you are instantiating a `Font`, so all font-related classes need to be loaded. I don't know, but there may even be some "font subsystem initialization" taking place. You get the picture.

So, as it stands, you cannot avoid this overhead.

You can try skipping the label and rendering the text yourself using "graphics", but I cannot promise that you will see any improvement this way.

You can also look into the `SplashScreen` component, one would hope that it would be optimized, so as to involve as few classes as possible, so as to load as quickly as possible, but I have no experience with it. And, you might not be able to add text to it, either by `JLabel` or by rendering it yourself, or if you do, you will probably suffer all the overhead that you are currently experiencing.
I also have another answer for you. Your problem might be related to this issue, which is still open:

**JDK-8179209 Text rendering has slow initialization time**

<https://bugs.openjdk.java.net/browse/JDK-8179209>

In short, java swing takes a long time to load fonts, and there is no solution to this other than to start loading fonts in the background, continue doing other application-startup-related things while the fonts are being loaded without trying to render any text, and then finally starting to render text once the fonts have been loaded. The openjdk issue contains some sample code for achieving this.