I have the following structure of my JOptionPane, with horizontal typing :
Howtoleavetypingfieldsvertically?
Hereistheclasscodebelow:
importjavax.swing.*;publicclassJOptionPaneMultiInput{publicstaticvoidmain(String[]args){JTextFieldfieldNome=newJTextField(5);JTextFieldfieldTelefone=newJTextField(5);JTextFieldfieldEmail=newJTextField(5);JPanelmyPanel=newJPanel();myPanel.add(newJLabel("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());
}
}
}