📄 jwindowdemo.java
字号:
import javax.swing.*;
import java.awt.*;
import java.net.*;
public class JWindowDemo extends JFrame {
Container container = getContentPane();
JProgressBar progress = null;
public JWindowDemo() {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
URL url = getClass().getResource("login.jpg");
if (url != null) {
container.add(new JLabel(new ImageIcon(url)), BorderLayout.CENTER);
}
progress = new JProgressBar(1, 100);
progress.setStringPainted(true);
progress.setString("数据加载中,清稍候......");
progress.setBackground(Color.white);
container.add(progress, BorderLayout.SOUTH);
Dimension screen = getToolkit().getScreenSize();
pack();
setLocation((screen.width - getSize().width) / 2,
(screen.height - getSize().height) / 2);
}
public void start() {
this.toFront();
Thread splashThread = new Thread() {
public void run() {
setVisible(true);
try {
for (int i = 0; i < 100; i++) {
Thread.sleep(100);
progress.setValue(progress.getValue() + 1);
}
}
catch (Exception e) {
e.printStackTrace();
}
dispose();
showFrame();
}
};
splashThread.start();
}
void showFrame() {
setSize(450, 450);
setVisible(true);
}
public static void main(String[] args) {
JWindowDemo splash = new JWindowDemo();
splash.start();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -