Creare uno splash screen in Java

Ecco una classe per la creazione di uno splash screen.

import java.awt.*;
import javax.swing.*;

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();

// 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;

// Build the splash screen
JLabel label = new JLabel(new ImageIcon("java-tip.gif"));
JLabel copyrt = new JLabel
("Copyright 2002, O'Reilly & Associates", 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, 10));

// Display it

// Wait a little while, maybe while loading resources
try { Thread.sleep(duration); } catch (Exception e) {}



public void showSplashAndExit() {



public static void main(String[] args) {

// Throw a nice little title page up on the screen first
SplashScreen splash = new SplashScreen(10000);

// Normally, we'd call splash.showSplash() and get on
// with the program. But, since this is only a test...



Explore posts in the same categories: Programming

One Comment su “Creare uno splash screen in Java”


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: