gpt4 book ai didi

Java 启动画面

转载 作者:太空宇宙 更新时间:2023-11-04 08:59:11 25 4
gpt4 key购买 nike

我使用 NetBeans 6.1 作为我的主要 IDE,在那里我无法运行 Sun 提供的这个启动屏幕示例(它抛出 nullpointerExeption)。但我可以使用此参数在命令行上运行它。

java -splash:文件名.gif SplashDemo

我不知道如何在 NetBeans 中注入(inject)命令行参数。请有人帮忙。

import java.awt.*;
import java.awt.event.*;

public class SplashDemo extends Frame implements ActionListener {

static void renderSplashFrame(Graphics2D g, int frame) {
final String[] comps = {"foo", "bar", "baz"};
g.setComposite(AlphaComposite.Clear);
g.fillRect(120, 140, 200, 40);
g.setPaintMode();
g.setColor(Color.BLACK);
g.drawString("Loading " + comps[(frame / 5) % 3] + "...", 120, 150);
}

public SplashDemo() {
super("SplashScreen demo");
setSize(300, 200);
setLayout(new BorderLayout());
Menu m1 = new Menu("File");
MenuItem mi1 = new MenuItem("Exit");
m1.add(mi1);
mi1.addActionListener(this);
this.addWindowListener(closeWindow);

MenuBar mb = new MenuBar();
setMenuBar(mb);
mb.add(m1);
final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash == null) {
System.out.println("SplashScreen.getSplashScreen() returned null");
return;
}
Graphics2D g = splash.createGraphics();
if (g == null) {
System.out.println("g is null");
return;
}
for (int i = 0; i < 100; i++) {
renderSplashFrame(g, i);
splash.update();
try {
Thread.sleep(90);
} catch (InterruptedException e) {
}
}
splash.close();
setVisible(true);
toFront();
}

public void actionPerformed(ActionEvent ae) {
System.exit(0);
}
private static WindowListener closeWindow = new WindowAdapter() {

public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
}
};

public static void main(String args[]) {
SplashDemo test = new SplashDemo();
}
}

最佳答案

转到项目属性(右键单击项目,然后选择属性)。从类别列表中选择“运行”项目。您可以在那里设置参数、VM 选项等。

关于Java 启动画面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1276327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com