0
現在、Netbean 6.9.1を使用しています。ビルド時に、プログラムにPNGファイルを追加したいだけです。私はいくつかのGUIボタンとラベルのアイコンとしてファイルを使用しています。しかし、クリーンを選択してメインプロジェクトをビルドするかメインプロジェクトをビルドし、IDEの外でJARファイルを実行すると、アイコンが表示されません。Netbeans6.9.1アイコンとしてのイメージ
イメージファイルを自分のプロジェクトフォルダに入れて、基本的にこの種類のコードを追加します。 コードが動作していますが、アイコンが表示されていませんでした。
void setMainForm(Resources r) {
UIManager.getInstance().setResourceBundle(r.getL10N("localize", "en"));
MainScreenForm main = new MainScreenForm(this, "Business Organiser");
if(mainMenu != null){
main.setTransitionInAnimator(mainMenu.getTransitionInAnimator());
main.setTransitionOutAnimator(mainMenu.getTransitionOutAnimator());
}else{
main.setTransitionOutAnimator(CommonTransitions.createFade(400));
}
mainMenu = main;
int width = Display.getInstance().getDisplayWidth(); //get the display width
elementWidth = 0;
Image[] selectedImages = new Image[DEMOS.length];
Image[] unselectedImages = new Image[DEMOS.length];
final ButtonActionListener bAListner = new ButtonActionListener();
for (int i = 0; i < DEMOS.length; i++) {
Image temp = r.getImage(DEMOS[i].getName() + "_sel.png");
selectedImages[i] = temp;
unselectedImages[i] = r.getImage(DEMOS[i].getName() + "_unsel.png");
final Button b = new Button(DEMOS[i].getName(), unselectedImages[i]);
b.setUIID("DemoButton");
b.setRolloverIcon(selectedImages[i]);
b.setAlignment(Label.CENTER);
b.setTextPosition(Label.BOTTOM);
mainMenu.addComponent(b);
b.addActionListener(bAListner);
b.addFocusListener(new FocusListener() {
public void focusGained(Component cmp) {
if (componentTransitions != null) {
mainMenu.replace(b, b, componentTransitions);
}
}
public void focusLost(Component cmp) {
}
});
demosHash.put(b, DEMOS[i]);
elementWidth = Math.max(b.getPreferredW(), elementWidth);
}
if(cols == 0){
cols = width/elementWidth;
}
int rows = DEMOS.length/cols;
mainMenu.setLayout(new GridLayout(rows, cols));
mainMenu.setDragMode(true);
mainMenu.addCommand(exitCommand);
mainMenu.addCommand(aboutCommand);
mainMenu.addCommand(rtlCommand);
mainMenu.addCommand(dragModeCommand);
mainMenu.addCommand(runCommand);
mainMenu.addCommandListener(this);
mainMenu.show();
}
あなたのリソースファイルで確認しましたか?イメージをリソースファイルに保存していますか?何か例外はありますか? – bharath