如何让我的 Java destop 应用程序在启动前显示图像?
我正在使用 NetBeans IDE 6.8(Mac 版本)。他们的 GUI 构建器的哪个工具可以帮助我完成此操作?
我想要的是在我向用户展示应用程序之前加载应用程序几秒钟时向用户展示图像。我怎样才能做到这一点?初始化
I'm using NetBeans IDE 6.8 (Mac Version). which tool of their GUI builder will assist me in doing this?
What I want is is to show the user an image while my application is loading for couple of seconds before I show him the application. How can I do that? initializing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您安装了 Java 6,请查看启动画面教程。
If you have Java 6 installed, checkout the Splash-Screen tutorial.
实际上,您可以通过在 java 程序中使用 -splash 标志来做到这一点......
例如,您想在运行 main.class 时显示图像splash.jpg,
那么您要做的是
java -splash:pathoftheimage/splash.jpg main
actually, you can do that by using the -splash flag in the java program...
for example, you want to show the image splash.jpg when you run main.class,
so what you will do is,
java -splash:pathoftheimage/splash.jpg main
由于您在 MAC 上运行,您可能无法访问 Java 6,因此必须自己构建启动屏幕。您应该在初始化周期中早期运行类似于以下的代码(即,以便闪屏对话框显示最长时间)。
As you're running on a MAC you probably won't have access to Java 6 and so will have to build the splashscreen yourself. You should run code similar to the following early in your initialisation cycle (i.e. so that the splashscreen dialog is displayed for the maximum amount of time).
如果您正在使用
NetBeans
...那么不用担心NetBeans
已经为您解决了这个问题。项目
后,右键单击
。属性
应用程序
启动屏幕
,浏览
您要显示的图像。如下图所示
当您执行此操作时,您的
图像
将会显示,但您将无法看到它。要看到它,您必须延迟
。为此,请执行以下步骤。下一个窗口
的出现
时间JFrame 代码
区域。Main Fun
中将会有run
乐趣。在
run
函数中只需编写以下代码。尝试{
Thread.sleep(以毫秒为单位的时间,如 4200);
//
在此处创建下一帧对象
}
catch(异常)
{
}
If you are using
NetBeans
... then don't worryNetBeans
has solved this problem for you.Right Click
On yourProject
after opening it.properties
Application
Splash Screen
,Browse
your image which you want to show.As shown in Pictures below
When you will do this , your
image
will show but you will not be able to see this. To See it, you have todelay time
ofappearence
ofnext window
. For this do these steps.JFrame code
area which you want to show next.Main Fun
there will berun
fun.Inside
run
function just write the following code.try{
Thread.sleep(time in milisecond just like 4200);
//
Create Next Frame Object Here
}
catch(Exception ex)
{
}