when i use border layout and centre alignment, my label content is appearing on left side but i need it on right side, suggest any change
here is my code

import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;


 class Welcum extends JFrame {
Container c;
JButton bFd,bAcct;
JLabel lWelcome;	
	
public Welcome() {
c=getContentPane();
setTitle("welcome");
setBounds(0,0,800,500);
//setLayout(BorderLayout);
bFd=new JButton("fdDetails");
c.add(BorderLayout.NORTH,bFd);

lWelcome=new JLabel("welcome");
lWelcome.setFont(new Font(Font.DIALOG,Font.BOLD,68));
c.add(BorderLayout.CENTER,lWelcome);

bAcct=new JButton("AccountDetails");
c.add(BorderLayout.SOUTH,bAcct);

setVisible(true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    	
    }
public class welcome{

	public static void main(String[] args){
		//new FrmAdd();
		new Welcome();
	}
}
    
}

Recommended Answers

All 2 Replies

Border layout is OK to get started, but if you're interested in good layout you soon run into its limitations. The ultimate manager is GridBagLayout, which will do anything you can dream of, although at the cost of a steep learning curve at the start. If you are going to do more layout-critical work in the future I would advise getting to grips with gridbag sooner rather than later, and don'w waste time on the simpler ones that you will outgrow anyway. If this is just a one-off throw-away projectthen maybe ignore layout managers and use absolute positions.

ok thanks for suggestion

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.