CompoundBorder Demo : Border « Swing JFC « Java

CompoundBorder Demo

CompoundBorder Demo
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;

public class ACompoundBorder {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Compound Borders");
    Border lineBorder = LineBorder.createBlackLineBorder();
    Border bevelBorder = BorderFactory.createRaisedBevelBorder();
    Border bevelLineBorder = new CompoundBorder(bevelBorder, lineBorder);
    JButton bevelLineButton = new JButton("Bevel Line");
    Border redBorder = BorderFactory.createLineBorder(;
    Border orangeBorder = BorderFactory.createLineBorder(;
    Border yellowBorder = BorderFactory.createLineBorder(Color.yellow);
    Border greenBorder = BorderFactory.createLineBorder(;
    Border blueBorder = BorderFactory.createLineBorder(;
    Border magentaBorder = BorderFactory.createLineBorder(Color.magenta);
    Border twoColorBorder = new CompoundBorder(magentaBorder, blueBorder);
    Border threeColorBorder = new CompoundBorder(twoColorBorder,
    Border fourColorBorder = new CompoundBorder(threeColorBorder,
    Border fiveColorBorder = new CompoundBorder(fourColorBorder,
    Border sixColorBorder = new CompoundBorder(fiveColorBorder, redBorder);
    JButton rainbowButton = new JButton("Rainbow");
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    frame.setSize(300, 100);


Related examples in the same category

1.Border Demo Border Demo
2.Different Swing bordersDifferent Swing borders
3.demonstrate the custom CurvedBorder classdemonstrate the custom CurvedBorder class
4.An example of the MatteBorder classAn example of the MatteBorder class
5.A simple demonstration of the LineBorder class built with rounded cornersA simple demonstration of the LineBorder class built with rounded corners
6.An example of using a titled border on a labelAn example of using a titled border on a label
7.Borders with a BevelBorder used on JLabels as a highlightBorders with a BevelBorder used on JLabels as a highlight
8.MatteBorder DemoMatteBorder Demo
9.TitledBorder DemoTitledBorder Demo
10.Custom Border SampleCustom Border Sample
11.How to create the borderHow to create the border
12.Solid border button border 3D borderSolid border button border 3D border
13.Oval borderOval border
14.Border of all kindsBorder of all kinds
16.Red Green BorderRed Green Border
18.TitledBorder 3TitledBorder 3
19.BevelBorder 2BevelBorder 2
20.Icon MatteBorderIcon MatteBorder
21.Soft BevelBorderSoft BevelBorder
22.Another TitledBorder 1Another TitledBorder 1
25.LineBorder DemoLineBorder Demo
26.Adding a Title to a Border
27.Create a title border from another border
28.Change border text Justification alignment style
29.Bottom Border
30.Right border
31.Rectangle border
32.Set title position
33.Flex Border