Change the OK Cancel string in JOptionPane

后端 未结 3 1640
情深已故
情深已故 2021-01-17 22:55

I was wondering is it possible to change the OK Cancel Button to custom string in java? I have

JOptionPane.showConfirmDialog(message, title, JOptionPane.OK_C         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 23:17

    Looks like instead of JOptionPane.showConfirmDialog you are going to have to use JOptionPane.showOptionDialog, which lets you supply your own texts as an array.

    Try the following:

    JOptionPane.showOptionDialog(null, 
            "Do you like this answer?", 
            "Feedback", 
            JOptionPane.OK_CANCEL_OPTION, 
            JOptionPane.INFORMATION_MESSAGE, 
            null, 
            new String[]{"Yes I do", "No I don't"}, // this is the array
            "default");
    

提交回复
热议问题