wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes GUI, please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GUI, please help" Watch "GUI, please help" New topic

GUI, please help

stab cooper

Joined: Feb 07, 2006
Posts: 6
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);
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41052
You're setting the GridLayout for something called "myPane", but you add all the elements to something called "i".

Ping & DNS - my free Android networking tools app
stab cooper

Joined: Feb 07, 2006
Posts: 6
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.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
basic scenario:
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
Consider Paul's rocket mass heater.
subject: GUI, please help
Similar Threads
SOME1 HELP ME URGENT- NullPointerException
array out of bounds and adding double contact
My First GUI.....maybe
not showing JLabel and TextField
Java uses or overrides a deprecated API?