更改JOptionPane中的“确定取消”字符串

编程入门 行业动态 更新时间:2024-10-28 14:28:28
本文介绍了更改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中的“确定取消”字符串

本文发布于:2023-10-29 20:41:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540697.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   JOptionPane

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!