我正在尝试创建一个对话框,要求用户输入并在下拉菜单选项中显示相同的输入。现在,需要在代码中设置输入。
class Main {
static JFrame frame = new JFrame();
public static void main (String [] args) throws
InterruptedException{
JDialog.setDefaultLookAndFeelDecorated(true);
Object[] selectionValues = { "Cat", "Dog", "Rate" };
String initialSelection = "Cat";
Object selection = JOptionPane.showInputDialog(null,
"Which player are you?",
"Welcome to Crappy birds!!",
JOptionPane.QUESTION_MESSAGE, null, selectionValues,
initialSelection);
System.out.println(selection);
}