我很抱歉造成误解。
所以也很容易。
1)你修改应用程序/重要文件/项目属性添加这一行:
#用于运行
run.args=-J-Dnetbeans.mainclass=splah.CustomStartup --nosplash
#for 从 IDE 运行
run.args.extra=-J-Dnetbeans.mainclass=splah.CustomStartup --nosplash
2)创建项目JavaApplication splah和类CustomStartup,然后构建jar并将其从dist复制到App/
package splah;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.lang.reflect.Method;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JWindow;
public class CustomStartup {
private static final String NB_MAIN_CLASS = "org.netbeans.core.startup.Main";
private static final int width = 500, height = 400;
public static void main(String[] args) throws Exception {
// do whatever you need here (e.g. show a custom login form)
System.out.println("Hello world! I am a custom startup class");
JDialog splash = new JDialog();
splash.setUndecorated(true);
//
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
splash.setBounds(width, height, (screenSize.width-width)/2, (screenSize.height-height)/2);
splash.setVisible(true);
// once you're done with that, hand control back to NetBeans
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
Class<?> mainClass = Class.forName(NB_MAIN_CLASS, true, classloader);
Object mainObject = mainClass.newInstance();
Method mainMethod = mainClass.getDeclaredMethod("main", new Class[]{String[].class});
mainMethod.invoke(mainObject, (Object) args);
splash.setVisible(false);
}
}
这门课不是我想出来的,我在某个地方找到的,但我不记得在哪里。
吉尔卡