Clicking the cancel button showInputDialogue

前端 未结 3 1488
花落未央
花落未央 2021-01-12 07:29

I have a question in regards to pressing the cancel button of my inputDialoguebox. I have asked a similar question before so I apologize if I seem to repeat myself.

<
3条回答
  •  死守一世寂寞
    2021-01-12 08:00

    It will always go in else condition even if cancel button is pressed. Check for,

    else if(input == JOptionPane.CANCEL_OPTION){
       System.out.println("Cancel is pressed");
    }
    

    add above code before last else statement explicitly, and handle cancel button pressed there.

提交回复
热议问题