[英]Bringing custom splash screen to custom about box in NetBeans platform applications
我正在嘗試創建NetBeans平台應用程序。 我創建了自己的啟動屏幕。 初始屏幕出現在默認的“關於”框中。
但是,當我自定義“關於”框時,將顯示NetBeans的默認啟動屏幕。
這是我的初始img的位置。 品牌/core/core.jar/org/netbeans/core/startup/splash.gif
這就是我嘗試訪問它並失敗的方式。
getClass().getResource("/org/netbeans/core/startup/splash.gif")
有人可以幫我在“關於”框中自定義img嗎?
是的,這很容易。 只需右鍵單擊項目-應用程序->品牌->啟動屏幕->瀏覽。 ..
對您的誤會深感抱歉。
因此也很容易。
1)您修改App /重要文件/項目屬性添加以下行:
#運行
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);
}
}
班級不是從我的頭上來的,我在某個地方找到了它,但是我不記得在哪里。
耶爾卡
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.