this is the result i am trying to:

http://beepleased.com/wordpress/wp-content/uploads/2013/11/2.jpg

and this is my code:

    panelSignUp.add(new JLabel("Name:"));
//      this.getContentPane().add(nameTextField,)
        panelSignUp.add(nameTextField);

     panelSignUp.add(new JLabel("Email:"));
//      this.getContentPane().add(nameTextField,)
        panelSignUp.add(emailTextField);

     panelSignUp.add(new JLabel("Username:"));
//      this.getContentPane().add(nameTextField,)
        panelSignUp.add(userNameTextField);

     panelSignUp.add(new JLabel("Password:"));
//      this.getContentPane().add(nameTextField,)
        panelSignUp.add(passwordTextField);

        panelSignUp.add(signDone);





this.setLayout(new GridLayout(5,2));
        this.setContentPane(panelSignUp);
        this.setSize(400, 300);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setVisible(true);

all go well, the only problem is that the elements are presenting in an order different from GridLayout....Q-/

Whats should i do?

  • JPanel uses FlowLayout as default LayoutManager inplemented in API

  • set GridLayout to JPanel (you already set to JFrame, then there you put JPanel with JComponents)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.