Results 1 to 3 of 3

Thread: Layout manager

  1. #1
    dacoolest is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Layout manager

    I want to create a gui window which should looks like a login page of a website.
    in the first row, a JLabel and a JTextField should be there to enter the username.
    in the second row, another JLabel and a JPasswordField should be placed to enter the password.
    in the third row, a login button should be placed.

    I created the gui but having problems with setting up the layout manager. Please help me to get it corrected. Thanks.

    Java Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class loginGui {
    	private JFrame frame;
    	private JPanel jp;
    	private JTextField userName;
    	private JPasswordField pass;
    	private JButton login;
    	private sessionManager sManager;
    	private List list;
    	public loginGui(sessionManager s){
    		sManager = s;
    		frame = new JFrame("Login");
    		jp = new JPanel(new GridLayout(3, 1, 10, 50));
    		userName = new JTextField("myname");
    		pass = new JPasswordField("mypass");
    		login = new JButton("Login");
    		login.addActionListener(new myActionListener() );
    	//	jp.setLayout(new GridLayout(3,1));
    	private class myActionListener implements ActionListener{
    		public void actionPerformed(ActionEvent e){
    			String n = userName.getText();
    			String p = pass.getText();
    			User u = new User();
    			u = sManager.list.validate(n, p);
    			if(u == null){
    				System.out.println("Invalid login");
    			else {
    				System.out.println("Valid login");
    				sManager.currentUser = u;

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Rep Power

  3. #3
    dacoolest is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Re: Layout manager

    Thanks. I got it properly set up with GridBagLayout.

Similar Threads

  1. Layout Manager suggestion
    By 0026sd in forum AWT / Swing
    Replies: 2
    Last Post: 09-19-2011, 05:54 PM
  2. Problem with layout manager
    By mDennis10 in forum New To Java
    Replies: 8
    Last Post: 09-05-2011, 03:02 AM
  3. Layout Manager
    By globo in forum New To Java
    Replies: 8
    Last Post: 11-01-2010, 12:19 AM
  4. Layout manager
    By Nicholas Jordan in forum Java Applets
    Replies: 2
    Last Post: 11-24-2008, 03:02 PM
  5. MiG Layout Manager 2.4
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-16-2007, 05:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts