【发布时间】:2013-03-20 11:39:06
【问题描述】:
我从 oracle 网站获得了这个下拉框示例:
Object[] possibilities = {"ham", "spam", "yam"};
String s = (String)JOptionPane.showInputDialog(
frame,
"Complete the sentence:\n"
+ "\"Green eggs and...\"",
"Customized Dialog",
JOptionPane.PLAIN_MESSAGE,
icon,
possibilities,
"ham");
//If a string was returned, say so.
if ((s != null) && (s.length() > 0)) {
setLabel("Green eggs and... " + s + "!");
return;
}
//If you're here, the return value was null/empty.
setLabel("Come on, finish the sentence!");
我只是想知道你如何改变每个选择的作用?例如,我是否需要更改语句if ((s != null) && (s.length() > 0)) { 中的某些内容,以便我可以编辑第一个字符串项?
【问题讨论】:
-
“每个选择会做什么”是什么意思?