问题描述
我如何在每行上显示带有多个JButtons
的JOptionPane.showinputDialog()
?我不是在谈论Yes
,No
,Cancel
按钮,而是在JOptionPane.showinputDialog
内容区域中显示的多个自定义标签JButtons
?
How would I go about displaying a JOptionPane.showinputDialog()
with multiple JButtons
on each line? I am not talking about the Yes
, No
, Cancel
buttons but multiple custom labeled JButtons
that displays in the content area of JOptionPane.showinputDialog
?
所以我也需要从JOptionPane
获取按下按钮的值.
so I would need to get the value of the button pressed from the JOptionPane
as well.
推荐答案
您可以将任何JComponents
放在 JOptionPane ,我看不到任何限制,JOptionPane
是相同的顶级容器为JFrame
,JDialog
或JWindow
,但与普通的Top-Level Containers
相反,JOptionPane
实现了来自内置功能Integer
的值,也意味着按钮YES
,NO
,OK
,CANCEL
和CLOSE
,
You can place any JComponents
to the JOptionPane, there I can't see any limits, JOptionPane
is same Top-Level Container as JFrame
, JDialog
or JWindow
, but in contrast with plain Top-Level Containers
, JOptionPane
has implemented return events from built-in funcionalities in Integer
value, meaning buttons YES
, NO
, OK
, CANCEL
and CLOSE
too,
将所有JButton放入数组
put all JButtons to the Array
String[] buttons = { "Yes", "Yes to all", "No", "Cancel".... };
int returnValue = JOptionPane.showOptionDialog(null, "Narrative", "Narrative",
JOptionPane.WARNING_MESSAGE, 0, null, buttons, buttons[i]);
System.out.println(returnValue);
这篇关于JOptionPane每行有多个按钮吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!