Java - How to add a JOptionPane for Yes and No options

前端 未结 4 839
别跟我提以往
别跟我提以往 2020-12-11 21:16

So, I\'ve read the Java API, but still can\'t seem to make heads or tails about how to do this. And believe me I have tried. I want an ActionListener to cause a message box

4条回答
  •  鱼传尺愫
    2020-12-11 21:53

    Try this..

      JOptionPane.showConfirmDialog(null, "Do you", "Message", 
                                    JOptionPane.YES_NO_OPTION);
    

    It will return 0 for Yes and 1 for No

提交回复
热议问题