Borders in Swing

import java.awt.Color;
import java.awt.Font;
import javax.swing.*;
import javax.swing.border.LineBorder;

public class BorderDemo1 extends JApplet {
	JPanel p1;
	JButton b[];
	LineBorder lb;

	@Override
	public void init() {
		getContentPane().add(p1 = new JPanel());
		b = new JButton[15];
		for (int i = 0; i < b.length; i++) {
			b[i] = new JButton("Button " + i);
			b[i].setFont(new Font("Arial", Font.BOLD, 15));
		}
		// user AWT style border
		b[0].setBorder(lb = new LineBorder(new Color(40, 40, 40), 3));
		p1.add(b[0]);

		b[1].setBorder(BorderFactory.createBevelBorder(2));
		p1.add(b[1]);

		// title border
		b[2].setBorder(BorderFactory.createTitledBorder("hello"));
		p1.add(b[2]);

		// title border
		b[3].setBorder(BorderFactory.createEtchedBorder(Color.red, Color.gray));
		p1.add(b[3]);

		b[4].setBorder(BorderFactory.createRaisedBevelBorder());
		p1.add(b[4]);

		b[5].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(1,
				2, 2)));
		p1.add(b[5]);
	}
}

Download

Borders in Java

Border factory Example - LineBorder,BevelBorder,TitledBorder,EtchedBorder etc
Border in Swing  
Custom Border


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code