更改JOptionPane中的“确定取消”字符串 [英] Change the OK Cancel string in JOptionPane

查看:143
本文介绍了更改JOptionPane中的“确定取消”字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在Java中将OK取消按钮更改为自定义字符串?
我有

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_CANCEL_OPTION);

现在,按钮将显示OK和Cancel。是否可以更改文本?
例如A和B或日文文本?

Right now, the button will show "OK" and "Cancel". Is it possible to change the text for that? for example into "A" and "B" or maybe japanese text?

谢谢

推荐答案

看起来不是 JOptionPane.showConfirmDialog 你将不得不使用 JOptionPane.showOptionDialog ,其中允许您将自己的文本作为数组提供。

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.

请尝试以下操作:

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");

这篇关于更改JOptionPane中的“确定取消”字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆