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
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: 42959
You're setting the GridLayout for something called "myPane", but you add all the elements to something called "i".
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
panel3 with button in frame's borderlayout.south
at the end of the constructor, just before frame.setVisible(true), have this line
I agree. Here's the link:
subject: GUI, please help
jQuery in Action, 3rd edition