?? guiwelcome.java
字號:
import java.awt.*;
import java.io.IOException;
import javax.swing.*;
public class GUIWelcome extends JFrame {
public static final int WIDTH = 380;
public static final int HEIGHT = 450;
Thread splashThread = null;
private JProgressBar progress;
private Container content;
GUIWelcome() {
setTitle("歡迎進入^=^");
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = screenSize.width;
int screenHeight = screenSize.height;
Dimension frameSize = getSize();
int x = (screenWidth - frameSize.width) / 2;
int y = (screenHeight - frameSize.height) / 2;
setLocation(x, y);
setResizable(false);
content = getContentPane();
content.setLayout(new BorderLayout());
JPanel southPanel = new JPanel(new FlowLayout());
progress = new JProgressBar(1, 100);
progress.setStringPainted(true);
progress.setString("程序載入中...");
progress.setBorderPainted(false);
progress.setBackground(Color.red);
southPanel.add(progress, BorderLayout.SOUTH);
content.add(southPanel, BorderLayout.SOUTH);
JPanel panel2 = new JPanel(new GridLayout(2, 1));
JLabel label1 = new JLabel(" 歡迎進入GPS導(dǎo)航系統(tǒng)...");
label1.setForeground(Color.gray);
label1.setFont(new Font("楷體", Font.BOLD, 20));
panel2.add(label1);
JLabel label2 = new JLabel(" Welcome ~~");
label2.setForeground(Color.gray);
label2.setFont(new Font("楷體", Font.BOLD, 20));
panel2.add(label2);
content.add(panel2, BorderLayout.NORTH);
JPanel panel1 = new JPanel();
JLabel label3 = new JLabel("");
JLabel label4 = new JLabel("");
ImageIcon icon2 = new ImageIcon("E:\\圖片\\ni.jpg");
ImageIcon icon3 = new ImageIcon("E:\\圖片\\wo.jpg");
label3.setIcon(icon2);
label4.setIcon(icon3);
panel1.add(label3);
panel1.add(label4);
panel1.setBackground(Color.green);
content.add(panel1, BorderLayout.CENTER);
}
/*
* public void start1() { splashThread = new Thread(); splashThread.start();
* }
*/
public class ThreadedIo extends Thread {
public void run() {
try {
for (int i = 0; i < 150; i++) {
Thread.sleep(10);
progress.setValue(i + 1);
}
GUI Main = new GUI();
Main.setVisible(true);
} catch (Exception ex) {
ex.printStackTrace();
}
dispose();
}
}
public static void main(String[] args) {
GUIWelcome frame = new GUIWelcome();
frame.setVisible(true);
GUIWelcome.ThreadedIo a=frame.new ThreadedIo();
a.start();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -