I am trying to design a GUI with a name, password and login button.I have a BorderLayout in the North for the GUI title. In the middle I have a JPanel with a BorderLayout.CENTER.However I am having problems separating name and password.It is alll cominh up on one line. How can I separate the two? I want the "Name" + its JTextField on top and "Passoword" + its Textfield below?I have tried the GridLayout but it doe not seem to work. Below is the code for my panel.
Please help and thank you in advance
i = new JPanel(); myPane.setLayout(new GridLayout(2,2)); sir = new JLabel("NAME"); i.add(sir); p = new JTextField (10); i.add(p); ss = new JLabel("PASSWORD"); i.add(ss); a = new JTextField(10); i.add(a); myPane.add(mid,BorderLayout.CENTER)
I have tried adding everything to myPane GridLayout and seem to be getting these large boxes. Can anyone help me preferrably with the code or something that I can use to separate these two? I do not think I am even suppose to use the GridLayout.
basic scenario: frame panel1 with label(title) in frame's borderLayout.north panel2(gridlayout(2,2,10,10)) with login fields in frame's borderlayout.center panel3 with button in frame's borderlayout.south at the end of the constructor, just before frame.setVisible(true), have this line frame.pack();