From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/SplashScreen.java | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/SplashScreen.java (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/SplashScreen.java') diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/SplashScreen.java b/Master/Reference Architectures and Patterns/hjp5/examples/SplashScreen.java new file mode 100644 index 0000000..29f3cd4 --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/SplashScreen.java @@ -0,0 +1,50 @@ +/* SplashScreen.java */ + +import javax.swing.*; +import javax.swing.border.*; +import java.awt.*; +import java.awt.event.*; + +public class SplashScreen +extends JWindow +{ + public SplashScreen(String image, String text) + { + JPanel contentPane = new JPanel(); + contentPane.setLayout(new BorderLayout()); + Border bd1 = BorderFactory.createBevelBorder( + BevelBorder.RAISED + ); + Border bd2 = BorderFactory.createEtchedBorder(); + Border bd3 = BorderFactory.createCompoundBorder(bd1, bd2); + ((JPanel)contentPane).setBorder(bd3); + ImageIcon icon = new ImageIcon(image); + contentPane.add(new JLabel(" ", JLabel.CENTER), BorderLayout.NORTH); + contentPane.add(new JLabel(icon, JLabel.CENTER), BorderLayout.CENTER); + contentPane.add(new JLabel(text, JLabel.CENTER), BorderLayout.SOUTH); + setContentPane(contentPane); + } + + public void showFor(int millis) + { + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + setLocation(dim.width / 3, dim.height / 3); + setSize(dim.width / 3, dim.height / 3); + setVisible(true); + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + } + setVisible(false); + } + + public static void main(String[] args) + { + SplashScreen intro = new SplashScreen( + "mine.gif", + "(C) Copyright 2000, J. Krüger, All Rights Reserved" + ); + intro.showFor(3000); + System.exit(0); + } +} \ No newline at end of file -- cgit v1.2.3