2017-04-27 1 views
0

시작시 다음을 나타내는 menu (menu_image)을 표시하는 프로그램을 작성 중입니다. 나는 약간의 문제가있다 : 나는 다른 창문의 꼭대기에 그것을 보여주고 싶지만, 나는 이것을 달성 할 수 없다.다른 윈도우 상단에 JOptionPane (드롭 다운 메뉴 포함) 표시

class Menu { 
    public String showMenu(){ 
     Object[] options = {"option1", "option2", "option3"}; 
     Object selectionObject = JOptionPane.showInputDialog(null, "Choose", "Menu", JOptionPane.PLAIN_MESSAGE, null, options, options[0]); 
     String selectionString = selectionObject.toString(); 
     return selectionString; 
    } 
} 

누군가 나를 도와 줄 수 있습니까? 버거의 제안을 바탕으로 사전

+0

대신 전달하는'null'의 첫 번째 매개 변수로 메인 창을 통과 ... 다음과 같은 방법으로 내 문제를 해결했다. – Berger

+0

[모든 윈도우 상단에 JOptionPane을 표시하는 방법] 가능한 복제본 (http://stackoverflow.com/questions/10880981/how-to-show-joptionpane-on-the-top-of-all-windows) – Berger

+1

좋아, 해냈어. 도와 줘서 고마워! –

답변

0

에 감사합니다, 나는

class Menu { 
    public String showMenu(){ 
     //i solved my problem adding the following 2 lines of code... 
     JFrame frame = new JFrame(); 
     frame.setAlwaysOnTop(true); 

     Object[] options = {"option1", "option2", "option3"}; 
     //...and passing `frame` instead of `null` as first parameter 
     Object selectionObject = JOptionPane.showInputDialog(frame, "Choose", "Menu", JOptionPane.PLAIN_MESSAGE, null, options, options[0]); 
     String selectionString = selectionObject.toString(); 
     return selectionString; 
    } 
} 
관련 문제