MatteBorderSample.java Source code

Java tutorial

Introduction

Here is the source code for MatteBorderSample.java

Source

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.MatteBorder;

public class MatteBorderSample {
    public static void main(String args[]) {
        JFrame frame = new JFrame("Sample Borders");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Icon diamondIcon = new ImageIcon("yourImage.gif");
        Border matteBorder = new MatteBorder(5, 10, 5, 10, diamondIcon);

        JLabel aLabel = new JLabel("Bevel");
        aLabel.setBorder(matteBorder);
        aLabel.setHorizontalAlignment(JLabel.CENTER);

        frame.add(aLabel);
        frame.setSize(400, 200);
        frame.setVisible(true);
    }
}