简体   繁体   English

如何使用NetBeans添加Splash Screen?

[英]How to add Splash Screen with NetBeans?

I wanted to add a simple .gif as Splash Screen to my application. 我想在我的应用程序中添加一个简单的.gif作为Splash Screen。 I'm using NetBeans and I've seen there are lots of bugs when doing this with it. 我正在使用NetBeans,我发现使用它时有很多错误。

I've tried to add the line SplashScreen-Image: to the manifest.mf file and -splash: at the run properties of my project (as I've read this last thing is only when running it from the IDE). 我试图将SplashScreen-Image:行添加到manifest.mf文件和-splash:在我的项目的运行属性中(因为我已经阅读过最后一件事,只有在从IDE运行它时)。 But it only works on the IDE, my .jar does not show any splash screen. 但它只适用于IDE,我的.jar不显示任何启动画面。 In fact, I opened the manifest.mf file compiled in the resulting .jar and it does not show the SplashScreen-Image line. 实际上,我打开了在生成的.jar中编译的manifest.mf文件,它没有显示SplashScreen-Image行。

I also tried to add it with the Netbeans option for it, but it does not work. 我也尝试使用Netbeans选项添加它,但它不起作用。

What can I do? 我能做什么? Maybe another way to compile the project? 也许是另一种编译项目的方法?

EDIT: 编辑:

I've tried to add the SplashScreen-Image line in the manifest file by opening the .jar with WinRAR, the Splash Screen appears but Java Virtual Machine throws an error and the application finishes. 我试图通过使用WinRAR打开.jar来在清单文件中添加SplashScreen-Image行,然后出现启动画面,但Java虚拟机会抛出错误并且应用程序完成。

Netbeans automatically generates the manifest each time you build the project, so you shouldn't be modifying it manually. 每次构建项目时,Netbeans都会自动生成清单,因此您不应手动修改它。

Instead, right click the project node and select properties. 而是,右键单击项目节点并选择属性。 Navigate to the "Application" entry and you will see a "Splash Screen". 导航到“应用程序”条目,您将看到“启动画面”。 Browse to the location of the file you want included. 浏览到要包含的文件的位置。

在此输入图像描述

Clean, build and run 清洁,构建和运行

Finally I made it downloading NetBeans 7.4. 最后我下载了NetBeans 7.4。 It has the option to add Custom Manifest Attributes in the Project Preferences, and it works correct 它可以选择在项目首选项中添加自定义清单属性 ,它可以正常工作

Create a real Splash Screen in java using Netbeans 使用Netbeans在java中创建一个真正的Splash Screen

step-1: How To create your .gif file 步骤1:如何创建.gif文件

    How to Make a GIF:
    http://www.myspacegens.com/handler.php?gen=animatedimage
    Complete your .gif file name Like `Splasemo.gif`

step-2: Your Project Name is/like "MySplash" Right click on Select Properties 步骤2:您的项目名称/如“MySplash”右键单击“选择属性”

    Select categories Name is "Run"
    And Input on VM options: 
    -splash:src/MyPackagename/SplashDemo.gif
    After OK Button..

step-3:Select Files or Shortcut( ctrl + 2 ) 步骤3:选择文件或快捷方式( ctrl + 2

    Click on your project File name like "manifest.mf"
    after input:
    SplashScreen-Image: MyPackagename/SplashDemo.gif

step-4:Splash Screen: Time Duration Set on Main() Methods using 步骤4:启动画面:使用Main()方法设置的时间持续时间

    Thread.sleep(3500);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM