MainClass(){
JFrame main = new JFrame("Login Form ");
main.setBounds(350,150,500,500);
main.setVisible(true);
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
name = new JTextField(10);
pass = new JTextField(10);
main.setLayout(new GridLayout(0,1));
JPanel pane = new JPanel();
main.add(pane);
main.add(new JLabel("Username: "));
pane.add(name);
//main.add(pane);
pane.add(new JLabel("Password: "));
pane.add(pass);
submit = new JButton("Submit");
pane.add(submit);
submit.addActionListener(new Handler());
}
I want to separate the text boxes in separate lines after the label username and name text box. I need to control the cursor to a new line.
If I was building a login screen, it might be laid out more along these lines (with the labels right justified and the button in it’s own panel – left as an exercise for the reader).