2013-02-24 93 views
1

我有幾個關於JOptionPane類的問題。爲什麼JOptionPane自定義按鈕默認退出?例如,如果我點擊清除,爲什麼程序關閉並且不清除文本框並保持不動?另外,如果我點擊向/從文件添加或檢索數據,爲什麼程序關閉?他們爲什麼不像JButtons在框架上反應?如何編寫自定義JOptionPane按鈕?

請您告訴我一個如何在沒有關閉窗口的情況下清除或轉到先前窗體的示例。

代碼:

String[] buttons = new String[] {"Add", "Clear", "Previous Window", "Retrieve"}; 
int example = JOptionPane.showOptionDialog(mypanel, mypanel, "Choose", 
    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, 
    null, buttons , buttons [0]);` 

回答