Program wyswietla w menu FILE i HELP.
Dlaczego gdy klikam zielony trójkąt ( run menu )
to raz wyswietla program z FILE i HELP...innym razem z samym HELP albo z samym FILE i na odwrót....czasami gdy klikne run menu to wyświetli sie tylko okienko....(bez FILE i bez HELP)....i tak sobie klikam i klikam i czasami jest ok a czasami nie ok....
jak zrobić aby cały czas mi dobrze wyświetlało?
mam taki kod z internetu:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class menu {
public static void main(String[] args) {
JFrame frame = new JFrame("Menu");
frame.setVisible(true);
frame.setSize(400,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menubar = new JMenuBar();
frame.setJMenuBar(menubar);
JMenu file = new JMenu("File");
menubar.add(file);
JMenuItem exit = new JMenuItem("Exit");
file.add(exit);
JMenu help = new JMenu("Help");
menubar.add(help);
JMenuItem about = new JMenuItem("About");
help.add(about);
class exitaction implements ActionListener{
public void actionPerformed (ActionEvent e){
System.exit(0);
}
}
exit.addActionListener(new exitaction());
}
}