⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splashscreen.java

📁 关于JAVA的代码连接数据库
💻 JAVA
字号:
package GradeManagement;

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

public class SplashScreen {
  private JWindow window;
  private Timer timer;

  public SplashScreen( Component component ) {
    window = new JWindow();
    window.getContentPane().add( component );
    window.addMouseListener(
         new MouseAdapter() {
            //当用户按鼠标左键时,隐藏和销毁窗口
            public void mousePressed( MouseEvent event ) {
               window.setVisible( false );
               window.dispose();
            }
         }
      ); // end call to addMouseListener
      window.pack();

      // 使窗口居中
      Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
      int width = window.getSize().width;
      int height = window.getSize().height;
      int x = (screenDimension.width - width) / 2 ;
      int y = (screenDimension.height - height) / 2 ;
      window.setBounds(x, y, width, height);
   } // 构造方法SplashScreen结束

   // 显示欢迎屏幕,设定延迟
   public void showSplash(int delay) {
      window.setVisible( true ); // 显示窗口
      timer = new Timer( delay,
         new ActionListener() {
            public void actionPerformed( ActionEvent event ) {
               window.setVisible( false );
               window.dispose();
               timer.stop();
            }
         }
      );
      timer.start();
   } // 方法showSplash结束

   public boolean isVisible() {
      return window.isVisible();
   }
} // 类SplashScreen结束

⌨️ 快捷键说明

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