aspose file tools*
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
Author

GUI, please help

stab cooper
Greenhorn

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);
myPane.add(mid,BorderLayout.CENTER)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
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
Greenhorn

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:
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();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI, please help