ツールバーにアイコンを追加しようとしていますが、どこに配置するのが最適ですか? 私のデスクトップ、またはプロジェクトファイルに新しいファイルを作成するか、すべての画像を追加する必要があります。これは、表示されておらず、これが私のコードです:
JToolBar toolBar = new JToolBar();
String[] iconFiles = {"pen-icon","",""};
String[] buttonLabels = {"New","Open","Save"};
icon = new ImageIcon[iconFiles.length];
Obutton = new JButton[buttonLabels.length];
for (int i = 0; i < buttonLabels.length; ++i) {
icon[i] = new ImageIcon(iconFiles[i]);
Obutton[i] = new JButton(icon[i]);
Obutton[i].setToolTipText(buttonLabels[i]);
if (i == 3)
toolBar.addSeparator();
toolBar.add(Obutton[i]);
}