i want this window to be like this

CYP BANKING SYSTEM
username [_________]
password [_________]
LOGIN

can anyone help me with the layout?, the flowlayout is just a single row!

Container logincontainer=getContentPane();
		logincontainer.setLayout( new  FlowLayout());
		JLabel Title=new JLabel("CYP BANKING SYSTEM");
		Title.setFont( new Font( "", Font.BOLD, 40 ) );
		JLabel Username=new JLabel("username");
		JLabel Password=new JLabel("password");
		JTextField UsernameText=new JTextField(10);
		JTextField PasswordText=new JPasswordField(10);
		JButton Login=new JButton("LOGIN");
		logincontainer.add(Title);
		logincontainer.add(Username);
		logincontainer.add(Password);
		logincontainer.add(UsernameText);
		logincontainer.add(PasswordText);
		logincontainer.add(Login);
		logincontainer.setSize( 300, 400 );
		logincontainer.setVisible(true);

Recommended Answers

All 4 Replies

Actually the FlowLayout will wrap around after you "fill" your first row. But I think you might find it easier to use something else. Might I suggest a BorderLayout, with a BoxLayout in the BorderLayout's CENTER panel to house the username and password fields.

i m a newbie in java, can you give me an example what you mean please ?

>Sun website is always best place to search for an tutorial, like now Lesson: Laying Out >Components Within a Container. Have funn reading it

NICE....really useful information...

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.