Hi,
I suggest you to study following example of BorderFactory class, which will definitely solve your confusion about it:
Code:
import javax.swing.BorderFactory;
public class BorderFactoryMain extends JFrame {
public MainClass(String name) {
getContentPane().setLayout(new FlowLayout());
JLabel labelTwo = new JLabel("www.java2s.com");
labelTwo.setBorder(BorderFactory.createEtchedBorder());
add(labelTwo);
JLabel labelThree01 = new JLabel("MatteBorder");
labelThree01.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
add(labelThree01);
JLabel labelSix1 = new JLabel("CompoundBorder");
Border one = BorderFactory.createEtchedBorder();
Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
labelSix1.setBorder(BorderFactory.createCompoundBorder(one, two));
add(labelSix1);
}
public static void main(String[] ardgs) {
JFrame frame1 = new MainClass("javax.swing.JButton");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.pack();
frame1.setVisible(true);
}
}
Bookmarks