Is there a multiple input JOptionPane in Java?

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

Answers


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.
}

Need Your Help

Strange percent sign in netstat (192.168.8.16%31621:5555)

linux bash netstat

Does anyone know what the %-sign in the netstat output below means? I can't find anything in the man page nor on the web.

How do I make a messagebox appear when the last item in a listbox is moved down?

c# listbox

When a user tries to move the last item down in a listbox, I need a messagebox to display that the item is already at the bottom. The app allows a user to enter more items to the list, so having the