Hi,
I have a problem with displaying icons in a menubar of my frame. Below is part of the code responsible for it from my frame's constructor:
Java Code:
public class MainFrame extends JFrame {
public MainFrame() {
super();
(...)
JMenuBar menuBar = new JMenuBar();
(...)
menu = new JMenu("Help");
menuBar.add(menu);
menu = new JMenu();
ImageIcon icon = new ImageIcon("grafiki/dodaj.png");
menu.add(new JMenuItem(icon));
menuBar.add(menu);
}
}
after compilation and run what I get is a simple frame with a menu bar containing a string "Help" but no icon next to it. But when I point with a cursor at a point the icon should be, then it displays me a white square of a 20x20 dimension (icon "dodaj.png" has the same dimension).
What should I do to load the icon into the menu bar and display it there properly?
Many thanks for help.
No comments:
Post a Comment