Reputation: 4829
I was wondering if there is a JOptionPane where you can get multiple inputs from a user instead of just one? If not, how could i accomplish this using some type of prompt. I am creating Battleship, and wanted to prompt the user to specify locations to place each ship.
Thanks,
Tomek
Upvotes: 3
Views: 9036
Reputation: 18599
The object that you pass in as the message to the JOptionPane can be graphical components, so something like this should work:
JPanel panel = new JPanel();
// Populate your panel components here.
int ret = JOptionPane.showConfirmDialog(parent, panel, "Title", JOptionPane.YES_NO_OPTION);
if ( ret == JOptionPane.YES_OPTION )
{
// Read component values.
}
Upvotes: 11