I’m trying to use a Swing Dialog so that the user can choose an item from a list of options with poolTeams being the name of that list. Like this:
String team = (String)JOptionPane.showInputDialog(frame, "Please choose a team:\n",
"Choose Team", JOptionPane.PLAIN_MESSAGE, null, poolTeams, "");
According to the documentation, poolTeams needs to be of type Object[] so I can’t use ArrayLists or anything like that.
The problem is; the items in poolTeams will vary so I can’t just populate it like
Object[] poolTeams = {"a", "b", "c"};
Is there a way I can make the program populate it automatically? If not, is there a different way I can offer the user a list in the dialog box?
Thanks!
1 Answer