我从 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)) {
以便可以编辑第一个字符串项?