带有自定义按钮的JOptionPane showInputDialog [英] JOptionPane showInputDialog with custom buttons

查看:346
本文介绍了带有自定义按钮的JOptionPane showInputDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将showInputDialog与自定义按钮一起使用,还是可以重命名showInputDialog上的确定和取消按钮。

解决方案

每个 JOptionPane 方法。选择一个通常可以让您访问所需的功能级别。在你的情况下,你正在寻找

  public static Object showInputDialog(Component parentComponent,
Object message,
字符串标题,
int messageType,
图标图标,
Object [] selectionValues,
Object initialSelectionValue)

在此处查看其javadoc: 的JOptionPane#showInputDialog 。注意你不会在这里更改按钮的颜色(因为它们依赖于外观),而是改变它们的文本(通常说得足够,因为你也可以在这里设置左侧对话框上显示的图标)。 / p>

Can i use showInputDialog with my custom buttons or can i rename "OK" and "Cancel" button on showInputDialog.

解决方案

There are a bunch of variants of each JOptionPane method. And choosing the one will usually give you access to the desired level of feature. In your case, you're looking for

public static Object showInputDialog(Component parentComponent,
                                 Object message,
                                 String title,
                                 int messageType,
                                 Icon icon,
                                 Object[] selectionValues,
                                 Object initialSelectionValue)

See its javadoc here: JOptionPane#showInputDialog. notice you won't change here the buttons colors (as they're look-and-feel dependant) but rather change their text (which is generally speaking enough, as you can also here set the icon displayed on dialog left side).

这篇关于带有自定义按钮的JOptionPane showInputDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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