Java tutorial
import javax.swing.Box; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; public class Main { public static void main(String[] args) { JTextField ipField = new JTextField(10); JTextField portField = new JTextField(10); JPanel panel = new JPanel(); panel.add(new JLabel("IP:")); panel.add(ipField); panel.add(Box.createHorizontalStrut(15)); panel.add(new JLabel("Port:")); panel.add(portField); int result = JOptionPane.showConfirmDialog(null, panel, "Enter Information", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { System.out.println("IP: " + ipField.getText()); System.out.println("Port: " + portField.getText()); } } }