我JOptionPane的代碼如下:獲取的JOptionPane
selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:");
這使得從一個文本框和一個確定和取消按鈕的輸入。我需要檢測是否點擊取消。
乾杯。
我JOptionPane的代碼如下:獲取的JOptionPane
selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:");
這使得從一個文本框和一個確定和取消按鈕的輸入。我需要檢測是否點擊取消。
乾杯。
檢查是否selectedSiteName == null。
如果用戶單擊「取消」或關閉對話框,則會出現這種情況。
請閱讀JOptionPane API並按照「如何使用對話框」中的Swing turorial鏈接進行工作示例。
if(selectedSiteName == JOptionPane.CANCEL_OPTION)
{
}
應該工作。