Ali*_*ssa 9 java user-interface swing awt splash-screen
大家好,我是Java的新手,并试图使闪屏或图像显示3秒钟.然后它会进入我的主程序.有没有人有想法如何做到这一点或可以链接到任何教程?
到目前为止,我已经做到了这一点,但不知道从哪里开始.
public static void main(String[] args)
{
splashInit(); // initialize splash overlay drawing parameters
appInit(); // simulate what an application would do
}
Run Code Online (Sandbox Code Playgroud)
Aly*_*mal 11
最简单的一种,就是创建JFrame
并添加你的screen
然后使用Thread.Sleep(long millies)
试试这段代码:
JWindow window = new JWindow();
window.getContentPane().add(
new JLabel("", new ImageIcon(new URL("http://docs.oracle.com/javase/tutorial/uiswing/examples/misc/SplashDemoProject/src/misc/images/splash.gif")), SwingConstants.CENTER));
window.setBounds(500, 150, 300, 200);
window.setVisible(true);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
window.setVisible(false);
JFrame frame = new JFrame();
frame.add(new JLabel("Welcome"));
frame.setVisible(true);
frame.setSize(300,100);
window.dispose();
Run Code Online (Sandbox Code Playgroud)
或者您可以使用 SplashScreen类创建启动画面
归档时间: |
|
查看次数: |
37056 次 |
最近记录: |