Example usage for javax.swing BorderFactory createMatteBorder

List of usage examples for javax.swing BorderFactory createMatteBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createMatteBorder.

Prototype

public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Icon tileIcon) 

Source Link

Document

Creates a matte-look border that consists of multiple tiles of a specified icon.

Usage

From source file:Main.java

public static void main(String[] argv) {
    ImageIcon icon = new ImageIcon("image.gif");
    MatteBorder matteBorder = (MatteBorder) BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
    JLabel component = new JLabel("label");
    component.setBorder(matteBorder);/*from w  w  w  . jav  a 2 s . c  o m*/

}

From source file:ButtonBorderTest.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Fourth Button");
    Container contentPane = frame.getContentPane();
    Icon icon = new ImageIcon("java2s.gif");
    JButton b = new JButton("Button!");
    Border bored = BorderFactory.createMatteBorder(10, 5, 10, 5, icon);
    b.setBorder(bored);/*from   w  ww. ja v a2s  .  co  m*/
    contentPane.add(b, BorderLayout.CENTER);
    frame.setSize(350, 200);
    frame.show();
}

From source file:Borders.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Borders");

    int center = SwingConstants.CENTER;
    JLabel labelOne = new JLabel("raised BevelBorder", center);
    labelOne.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    JLabel labelTwo = new JLabel("EtchedBorder", center);
    labelTwo.setBorder(BorderFactory.createEtchedBorder());
    JLabel labelThree = new JLabel("MatteBorder", center);
    labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
    JLabel labelFour = new JLabel("TitledBorder", center);
    Border etch = BorderFactory.createEtchedBorder();
    labelFour.setBorder(BorderFactory.createTitledBorder(etch, "Title"));
    JLabel labelFive = new JLabel("TitledBorder", center);
    Border low = BorderFactory.createLoweredBevelBorder();
    labelFive// w  ww.ja  v a2  s  . c  o m
            .setBorder(BorderFactory.createTitledBorder(low, "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM));
    JLabel labelSix = new JLabel("CompoundBorder", center);
    Border one = BorderFactory.createEtchedBorder();
    Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
    labelSix.setBorder(BorderFactory.createCompoundBorder(one, two));

    frame.setLayout(new GridLayout(3, 2));
    frame.add(labelOne);
    frame.add(labelTwo);
    frame.add(labelThree);
    frame.add(labelFour);
    frame.add(labelFive);
    frame.add(labelSix);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:RedBlueBox.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));
    JComponent comp = new RedBlueBox();
    comp.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.PINK));
    contentPane.add(comp);/* w w w .  j a v a 2  s.  com*/
    comp = new RedBlueBox();
    contentPane.add(comp);
    frame.setSize(300, 200);
    frame.show();
}

From source file:GridLayoutDemo.java

private static JComponent createComponent(String s) {
    JLabel l = new JLabel(s);
    l.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.DARK_GRAY));
    l.setHorizontalAlignment(JLabel.CENTER);
    return l;//ww w .  jav  a  2 s  . c  om
}

From source file:BoxLayoutDemo.java

private static JComponent createComponent(String s) {
    JLabel l = new JLabel(s);
    l.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.DARK_GRAY));
    l.setHorizontalAlignment(JLabel.CENTER);
    l.setAlignmentX(Component.CENTER_ALIGNMENT); //use middle of row
    return l;/*from  ww w .  j a v  a2  s  .  c  o m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createMatteBorder(2, 5, 2, 5, Color.BLUE));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/*  w  w  w. j  a v  a2s  .  c o m*/
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(200, 200));
    add(label, BorderLayout.CENTER);
    setUndecorated(true);//  w  w w.j a  v  a2 s  .  c  o  m
    getRootPane().setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.RED));
    setVisible(true);

}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder());

    add(labelTwo);//  w  ww .ja  v  a 2s  . c  o  m

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink)));
    add(labelFour);

}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createCompoundBorder());

    add(labelTwo);/*ww  w  . j av  a 2s.  co m*/

    JLabel labelThree = new JLabel("MatteBorder");
    labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
    add(labelThree);

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink),
                    "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM));
    add(labelFour);

    JLabel labelSix = new JLabel("CompoundBorder");
    Border one = BorderFactory.createEtchedBorder();
    Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
    labelSix.setBorder(BorderFactory.createCompoundBorder(one, two));
    add(labelSix);

}