How to get JOptionPane with three text fields?

Build a JPanel (supose it's named inputPanel) with the three JtextFields to input and then do this.

Build a JPanel (supose it's named inputPanel) with the three JtextFields to input and then do this: if (JOptionPane. YES_OPTION == JOptionPane. ShowconfirmDialog( parentComponent, inputPanel, "Enter your data", JOptionPane.

YES_NO_OPTION) { // retrieve data from the JTextFields and do things } else { // User close the dialog, do things... or not }.

Reformatted code; please revert if incorrect. – trashgod Apr 28 '10 at 18:10.

You can't do that with JOptionPane. Create a JDialog and add three JTextField's to it instead. A JDialog will block the caller when you call setVisible(true), so it's easy to create a dialog that waits for user input before it returns.

ShowInputMessageDialog and its brethren are simple ways to whip up a simple "standard" dialog. For more complicated dialogs, I'm pretty sure you'll have to subclass JDialog or such.

As Telcontar has suggested you can add Swing components (like a JPanel) to an option pane. So it is easy to take advantage of the automatic creation of buttons rather than do it from scratch by building your own JDialog. However, there is one small problem.

The focus will be on the first button, not on the first component of your panel. To get around this problem you can try the solution presented in Dialog Focus.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions