我正在尝试创建一些对话框窗口,它可以引导我通过面板。所以我就这样做了。这对我来说有点好。但我有问题,如何摆脱图标和突出显示的选项?
Object[] options = {"one",
"two"};
int n = JOptionPane.showOptionDialog(this, "", "select one",
JOptionPane.CLOSED_OPTION,
JOptionPane.PLAIN_MESSAGE,
null,
options,
null);
已将选定对象设置为空,图标设置为空。但它们没有任何效果。当我添加 PLAIN_MESSAGE 时,图标消失了,但我仍然突出显示其中一个按钮,第二个按钮向右对齐,我需要居中对齐,请帮忙。 :)
最佳答案
but i still have highlited one of the buttons
这是 JOptionPane 的默认行为。
查看Dialog Focus了解您可以使用的方法,该方法允许您将自己的组件添加到选项 Pane 并将焦点放在该组件上。
the buttons are aligned to right, i need center aligment,
这又是默认设置,没有简单的方法可以更改它。
要进行完全自定义,您需要创建一个自定义 JDialog。
关于java - JOptionPane Swing ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20382517/