splashscreen.java

来自「JAVA写的一个机器人程序」· Java 代码 · 共 42 行

JAVA
42
字号
package rebot;

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

public class SplashScreen extends JWindow {
    private int duration;
    public SplashScreen(int d) {
        duration = d;
    }

    public void showSplash() {
        JPanel content = (JPanel) getContentPane();
        int width = 182;
        int height = 211;
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width - width) / 2;
        int y = (screen.height - height) / 2;
        setBounds(x, y, width, height);

        URL url1;
        url1 = getClass().getResource("/image/doraemon.gif");
        JLabel label = new JLabel(new ImageIcon(url1));
        label.setOpaque(false);
        content.setBackground(new Color(88, 183, 216));
        content.add(label);
        setVisible(true);

        try {
            Thread.sleep(duration);
        } catch (Exception e) {

        }
        setVisible(false);
    }

    public void showSplashAndExit() {
        showSplash();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?