0
JMenu
팝업과 관련된 문제가 있습니다. 때때로 만 작동합니다. 때때로 나는 자바 팝업을 전혀 얻지 못한다. 가끔 내 파일 및 수정 옵션이 완전히 누락되었습니다. 이것이 내 코드의 모습입니다.JMenu 팝업은 가끔씩 만 작동합니다.
import javax.swing.*;
public class menu {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
JFrame f = new JFrame();
f.setVisible(true);
f.setSize(400,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
JMenuBar mb = new JMenuBar();
JMenu file = new JMenu ("File");
mb.add(file);
JMenu edit = new JMenu("Edit");
mb.add(edit);
f.setJMenuBar(mb);
}
}
트릭을 해 주셔서 감사합니다 :). – cokedude
나는 Event Dispatching Thread를 올바르게 사용하고 있습니까? 테스트를 위해 이것을 사용해야합니까? http://docs.oracle.com/javase/8/docs/api/javax/swing/SwingUtilities.html#isEventDispatchThread-- – cokedude
아니요 (EDT의 컨텍스트에서 UI를 초기화하는) 아니며 그렇습니다. SwingUtilites.inokeLater' 또는'EventQueue.invokeLater'를 사용할 필요가 있습니다. 둘 다 똑같은 일을합니다. – MadProgrammer