1
I have the following structure of my Joptionpane, with horizontal typing fields:

How to vertical the input fields?
Here below is the class code:
import javax.swing.*;
public class JOptionPaneMultiInput {
public static void main(String[] args) {
JTextField fieldNome = new JTextField(5);
JTextField fieldTelefone = new JTextField(5);
JTextField fieldEmail = new JTextField(5);
JPanel myPanel = new JPanel();
myPanel.add(new JLabel("Digite Nome:"));
myPanel.add(fieldNome);
myPanel.add(Box.createHorizontalStrut(15)); // a spacer
myPanel.add(new JLabel("Digite Telefone:"));
myPanel.add(fieldTelefone);
myPanel.add(Box.createHorizontalStrut(15)); // a spacer
myPanel.add(new JLabel("Digite Email:"));
myPanel.add(fieldEmail);
int result = JOptionPane.showConfirmDialog(null, myPanel,
"Entrada de valores", JOptionPane.OK_CANCEL_OPTION);
if (result == JOptionPane.OK_OPTION) {
System.out.println("Nome value: " + fieldNome.getText());
System.out.println("Telefone value: " + fieldTelefone.getText());
System.out.println("Email value: " + fieldEmail.getText());
}
}
}

Pedro, you need to add one
LayoutManagerin hisJPanel. There are many options, theLayoutManagerideal will depend on ease and taste. Have a look at the list: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html. Recommend or theGridLayoutor theSpringLayout.– Wakim
Are you using any IDE?
– ptkato
@Patrick I’m using the eclipse
– Pedro Rangel
Ever tried to ride a
JPanelon the prototyper and then just call it?– ptkato
@Patrick with the tip Wakim I think I got....
– Pedro Rangel