初级问题求源码:如何在程序启动时显示一个splash窗口

MadLee 2003-08-21 09:43:57
如何在程序启动时显示一个splash窗口,在这个窗口里面显示一副jpg图片。
希望能给出比较完整的源代码。
谢谢。
...全文
29 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
MadLee 2003-08-21
  • 打赏
  • 举报
回复
非常感谢
hexubing 2003-08-21
  • 打赏
  • 举报
回复
赞成楼上
javahui 2003-08-21
  • 打赏
  • 举报
回复
JLabel splashLabel;
JWindow splashScreen;



public void showSplashScreen()
{
splashLabel = new JLabel(new ImageIcon(getClass().getResource("/logo.gif")));

splashScreen = new JWindow();
splashScreen.getContentPane().add(splashLabel);
splashScreen.pack();
Rectangle screenRect = getGraphicsConfiguration().getBounds();
splashScreen.setLocation(
screenRect.x + screenRect.width/2 - splashScreen.getSize().width/2,
screenRect.y + screenRect.height/2 - splashScreen.getSize().height/2);


splashScreen.show();
}

public void hideSplash()
{
if(splashScreen!=null)
{
splashScreen.setVisible(false);
splashScreen.dispose();
splashScreen = null;
splashLabel = null;
}

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧