Example usage for javax.swing.border MatteBorder MatteBorder

List of usage examples for javax.swing.border MatteBorder MatteBorder

Introduction

In this page you can find the example usage for javax.swing.border MatteBorder MatteBorder.

Prototype

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

Source Link

Document

Creates a matte border with the specified insets and tile icon.

Usage

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Color Matted Border");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border solidBorder = new MatteBorder(10, 5, 2, 20, Color.RED);
    JButton solidButton = new JButton("10x5x2x20");
    solidButton.setBorder(solidBorder);/*w  ww  .ja v a2 s. co  m*/
    Container contentPane = frame.getContentPane();
    contentPane.add(solidButton, BorderLayout.CENTER);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:MatteBorderSample.java

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);//w  w w.  ja v  a  2  s . c  o  m
    aLabel.setHorizontalAlignment(JLabel.CENTER);

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

From source file:IconMatteBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Icon Matted Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Icon diamondIcon = new DiamondIcon(Color.red, true, 10, 10);
    Border diamondBorder = new MatteBorder(10, 10, 10, 10, diamondIcon);
    JButton diamondButton = new JButton("diamonds");
    diamondButton.setBorder(diamondBorder);
    Icon diamondIcon2 = new ImageIcon("diamond.gif");
    Border diamondBorder2 = new MatteBorder(36, 40, 36, 40, diamondIcon2);
    JButton diamondButton2 = new JButton("diamonds2");
    diamondButton2.setBorder(diamondBorder2);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(2, 1));
    contentPane.add(diamondButton);/* ww w  .j  av  a2s.c  om*/
    contentPane.add(diamondButton2);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:ATitledBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border thisBorder = BorderFactory.createTitledBorder("Easy");
    Icon thatIcon = new ImageIcon("diamond.gif");
    Border thatBorder1 = new MatteBorder(18, 20, 18, 20, thatIcon);
    Border thatBorder2 = new TitledBorder(thatBorder1, "Harder");
    Font font = new Font("Serif", Font.ITALIC, 12);
    Border thatBorder = new TitledBorder(thatBorder2, "Harder", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM,
            font, Color.red);//from   w  w  w.  j a v a 2  s. c o  m
    JButton thisButton = new JButton("Easy");
    thisButton.setBorder(thisBorder);
    JButton thatButton = new JButton("Harder");
    thatButton.setBorder(thatBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(thisButton);
    contentPane.add(thatButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border thisBorder = BorderFactory.createTitledBorder("Easy");
    Icon thatIcon = MetalIconFactory.getFileChooserHomeFolderIcon();

    Border thatBorder1 = new MatteBorder(18, 20, 18, 20, thatIcon);
    Border thatBorder2 = new TitledBorder(thatBorder1, "Harder");

    Font font = new Font("Serif", Font.ITALIC, 12);
    Border thatBorder = new TitledBorder(thatBorder2, "Hardest", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM,
            font, Color.RED);//from  w w w.  ja va2 s.c  o m

    JButton thisButton = new JButton("Easy");
    thisButton.setBorder(thisBorder);
    JButton thatButton = new JButton("Harder");
    thatButton.setBorder(thatBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(thisButton);
    contentPane.add(thatButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    List<Phone> phones = new ArrayList<>();
    phones.add(new Phone("Galaxy", 12345));
    phones.add(new Phone("iPhone", 12345));

    JPanel panel = new JPanel(new GridLayout(0, 1));
    for (Phone phone : phones) {
        String html = "<html><body style='width:100px'>Phone: " + phone.getName() + "<br/>Model: "
                + phone.getModel() + "</body></html>";
        JLabel label = new JLabel(html);
        label.setBorder(new MatteBorder(0, 0, 1, 0, Color.BLACK));
        panel.add(label);//w w w  .  ja  va2 s. c  o m

    }
    JOptionPane.showMessageDialog(null, panel, "Phone List", JOptionPane.PLAIN_MESSAGE);
}

From source file:BorderSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Sample Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border bevelBorder = new BevelBorder(BevelBorder.RAISED, Color.red, Color.red.darker(), Color.pink,
            Color.pink.brighter());
    Border emptyBorder = new EmptyBorder(5, 10, 5, 10);
    Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, Color.red, Color.pink);
    Border lineBorder = new LineBorder(Color.red, 5);
    Icon diamondIcon = new DiamondIcon(Color.red);
    Border matteBorder = new MatteBorder(5, 10, 5, 10, diamondIcon);
    Border softBevelBorder = new SoftBevelBorder(BevelBorder.RAISED, Color.red, Color.red.darker(), Color.pink,
            Color.pink.brighter());
    Font font = new Font("Serif", Font.ITALIC, 12);
    Border titledBorder = new TitledBorder(lineBorder, "Hello", TitledBorder.LEFT, TitledBorder.BELOW_BOTTOM,
            font, Color.red);/*from w  w  w .ja v  a2s  . c om*/
    Border compoundBorder = new CompoundBorder(lineBorder, matteBorder);

    JLabel bevelLabel = new JLabel("Bevel");
    bevelLabel.setBorder(bevelBorder);
    bevelLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel emptyLabel = new JLabel("Empty");
    emptyLabel.setBorder(emptyBorder);
    emptyLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel etchedLabel = new JLabel("Etched");
    etchedLabel.setBorder(etchedBorder);
    etchedLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel lineLabel = new JLabel("Line");
    lineLabel.setBorder(lineBorder);
    lineLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel matteLabel = new JLabel("Matte");
    matteLabel.setBorder(matteBorder);
    matteLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel softBevelLabel = new JLabel("Soft Bevel");
    softBevelLabel.setBorder(softBevelBorder);
    softBevelLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel titledLabel = new JLabel("Titled");
    titledLabel.setBorder(titledBorder);
    titledLabel.setHorizontalAlignment(JLabel.CENTER);
    JLabel compoundLabel = new JLabel("Compound");
    compoundLabel.setBorder(compoundBorder);
    compoundLabel.setHorizontalAlignment(JLabel.CENTER);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(2, 4, 5, 5));
    contentPane.add(bevelLabel);
    contentPane.add(emptyLabel);
    contentPane.add(etchedLabel);
    contentPane.add(lineLabel);
    contentPane.add(matteLabel);
    contentPane.add(softBevelLabel);
    contentPane.add(titledLabel);
    contentPane.add(compoundLabel);
    frame.setSize(400, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static JLabel createVerticalLineLabel() {
    MatteBorder mb = new MatteBorder(0, 1, 0, 0, Color.black);
    JLabel label = new JLabel();
    label.setBorder(mb);//  w  w  w .  j  ava  2  s  . co  m
    return label;
}

From source file:Main.java

public static JLabel createHorizontalLineLabel() {
    MatteBorder mb = new MatteBorder(0, 0, 1, 0, Color.black);
    JLabel label = new JLabel();
    label.setBorder(mb);/*w  w  w.  ja  v a  2  s .  c o m*/
    return label;
}

From source file:MatteExample.java

public MatteExample() {
    super(true);// w ww.  j a  v  a2 s  .  com
    this.setLayout(new GridLayout(1, 2, 5, 5));

    JLabel label1 = new JLabel("Matte Border");
    JLabel label2 = new JLabel("Matte Border (Icon)");

    label1.setHorizontalAlignment(JLabel.CENTER);
    label2.setHorizontalAlignment(JLabel.CENTER);

    Icon icon = new ImageIcon("yourFile.gif");
    MatteBorder matte = new MatteBorder(35, 35, 35, 35, Color.blue);
    MatteBorder matteicon = new MatteBorder(35, 35, 35, 35, icon);
    label1.setBorder(matte);
    label2.setBorder(matteicon);

    add(label1);
    add(label2);
}