Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6900303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:31:45+00:00 2026-05-27T07:31:45+00:00

I am using JWindow to display my splash screen during the application start up.

  • 0

I am using JWindow to display my splash screen during the application start up. however it will not appear in front of all windows as it should, and it will not disappear as well.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

public class MySplash {
    public static MySplash INSTANCE;
    private static JWindow jw;

    public MySplash(){
        createSplash();
    }

    private void createSplash() {
        jw = new JWindow();
        JPanel content = (JPanel) jw.getContentPane();
        content.setBackground(Color.white);

        // Set the window's bounds, centering the window
        int width = 328;
        int height = 131;
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        jw.setBounds(x, y, width, height);

        // Build the splash screen
        JLabel label = new JLabel(new ImageIcon("splash.jpg"));
        JLabel copyrt = new JLabel("SplashScreen Test",
            JLabel.CENTER);
        copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
        content.add(label, BorderLayout.CENTER);
        content.add(copyrt, BorderLayout.SOUTH);
        Color oraRed = new Color(156, 20, 20, 255);
        content.setBorder(BorderFactory.createLineBorder(oraRed, 0));

    }

    public synchronized static MySplash getInstance(){
        if(INSTANCE==null){
            INSTANCE = new MySplash();
        }

        return INSTANCE;

    }

    public void showSplash(){
        jw.setAlwaysOnTop(true);
        jw.toFront();
        jw.setVisible(true);
        return;
    }

    public void hideSplash(){
        jw.setAlwaysOnTop(false);
        jw.toBack();
        jw.setVisible(false);
        return;
    }
}

So in my main class which extends JFrame, I call my splash screen by

    SwingUtilities.invokeLater(new Runnable(){

        @Override
        public void run() {
            MySplash.getInstance().showSplash();
        }

    });

However, the JWindow appears behind the all open instances of windows on my computer. Hiding the JWindow also doesn’t work.

    SwingUtilities.invokeLater(new Runnable(){

        @Override
        public void run() {
            MySplash.getInstance().hideSplash();
        }

    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:31:45+00:00Added an answer on May 27, 2026 at 7:31 am

    You might want to take a look at java.awt.SplashScreen. However, if your heart is set on your solution:

    Looking at Window#toFront,

    If this Window is visible, brings this Window to the front and may
    make it the focused Window.

    Try making your JWindow visible before bringing it to the front.

    I’m not sure why your JWindow isn’t hiding, that part works for me.

    /e1
    If you’re trying to implement a singleton pattern, you should make your constructor and field private. You might also want to take a look at What is an efficient way to implement a singleton pattern in Java?.

    /e2
    The returns at the end of your showSplash and hideSplash methods are unnecessary, the method would have returned at that point anyways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using Android TelephonyManager an application can obtain the state of data activity over the
using a binary search tree I need to add to a vector all int
(Using MVC 2) From inside my controller action, I need to display the url:
In the application I'm developping (in Java/swing), I have to show a full screen
Im working in Java Swing using JWindows to display images... Ive made different JLabels
Using Java, how can I extract all the links from a given web page?
Using C#, I want to format a decimal to only display two decimal places
Using Browserlab, it appears that the background image is not centred in Firefox7 for
I have this main.Boot which is actually a splash screen requires to be always

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.