CompoundBorderLineLineBorder.java Source code

Java tutorial

Introduction

Here is the source code for CompoundBorderLineLineBorder.java

Source

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class CompoundBorderLineLineBorder extends JFrame {

    public CompoundBorderLineLineBorder() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
        JLabel label;

        label = new JLabel("Compound - red inside green lines");
        label.setBorder(BorderFactory.createCompoundBorder(new LineBorder(Color.green), new LineBorder(Color.red)));
        panel.add(label);
        getContentPane().add(panel);
        pack();
    }

    public static void main(String[] args) {
        CompoundBorderLineLineBorder s = new CompoundBorderLineLineBorder();
        s.setVisible(true);
    }
}