joki00
joki00

Reputation: 83

Container alingments in jframe

I want to align components in flowlayout.is it possible? Here is my code:

JPanel ppanel = new JPanel(new FlowLayout());
    ppanel.add(text);
    ppanel.add(btnLogin);
    ppanel.add(btnRegister);

    text.setAlignmentX(LEFT_ALIGNMENT);
    btnLogin.setAlignmentX(RIGHT_ALIGNMENT);
    btnRegister.setAlignmentX(RIGHT_ALIGNMENT);

picture

i want to move Label "Welcome" to far left and 2 buttons for far right Any suggestions?

Upvotes: 1

Views: 21

Answers (1)

Priyamal
Priyamal

Reputation: 2989

         yourpanel.setLayout(new BorderLayout());
         yorpanelpanel.add(yourbutton,BorderLayout.WEST);
         yorpanelpanel.add(yourbutton,BorderLayout.EAST);

you might wanna try this code,

Upvotes: 1

Related Questions