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 Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));
    ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage("matte.gif"));
    simplePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
            BorderFactory.createMatteBorder(-1, -1, -1, -1, icon)));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/*  w w  w.  j  av a  2  s .  co m*/
}

From source file:Main.java

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

    add(labelTwo);/*from w w w .  j  a v a2 s  .  c  o 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);

}

From source file:Main.java

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

    add(labelTwo);/*from   ww w .j a  v  a  2 s.  c o 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, MetalIconFactory.getFileChooserHomeFolderIcon()),
            "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);

}

From source file:Main.java

public Main() {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.red, Color.black));

    add(labelTwo);/*from  ww  w.j a v  a2s .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);

}

From source file:BorderTest.java

public BorderTest() {
    JPanel p = new JPanel();
    Border[] border = new Border[] { BorderFactory.createEtchedBorder(),
            BorderFactory.createTitledBorder("Border types"), BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createRaisedBevelBorder(), BorderFactory.createEtchedBorder(),
            BorderFactory.createLineBorder(Color.blue),
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.blue), BorderFactory.createEmptyBorder()

    };/*from   w ww .  j  ava2  s .c  o  m*/
    p.setLayout(new GridLayout(border.length, 0, 3, 3));

    for (int i = 0; i < border.length; i++) {
        JPanel borderPanel = new JPanel();
        borderPanel.setBorder(border[i]);
        p.add(borderPanel);
    }
    getContentPane().add(p, "Center");
    setTitle("BorderTest");
    setSize(600, 400);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

From source file:Main.java

private ListCellRenderer<? super String> getRenderer() {
    return new DefaultListCellRenderer() {
        @Override//  w  ww .j  a  v  a 2s.com
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index,
                    isSelected, cellHasFocus);
            listCellRendererComponent.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
            return listCellRendererComponent;
        }
    };
}

From source file:List.java

public void init() {
    Container cp = getContentPane();
    t.setEditable(false);//from w  w  w . j  av  a 2 s . c om
    cp.setLayout(new FlowLayout());
    // Create Borders for components:
    Border brd = BorderFactory.createMatteBorder(1, 1, 2, 2, Color.BLACK);
    lst.setBorder(brd);
    t.setBorder(brd);
    // Add the first four items to the List
    for (int i = 0; i < 4; i++)
        lItems.addElement(flavors[count++]);
    // Add items to the Content Pane for Display
    cp.add(t);
    cp.add(lst);
    cp.add(b);
    // Register event listeners
    lst.addListSelectionListener(ll);
    b.addActionListener(bl);
}

From source file:BorderTest.java

public BorderFrame() {
    setTitle("BorderTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    demoPanel = new JPanel();
    buttonPanel = new JPanel();
    group = new ButtonGroup();

    addRadioButton("Lowered bevel", BorderFactory.createLoweredBevelBorder());
    addRadioButton("Raised bevel", BorderFactory.createRaisedBevelBorder());
    addRadioButton("Etched", BorderFactory.createEtchedBorder());
    addRadioButton("Line", BorderFactory.createLineBorder(Color.BLUE));
    addRadioButton("Matte", BorderFactory.createMatteBorder(10, 10, 10, 10, Color.BLUE));
    addRadioButton("Empty", BorderFactory.createEmptyBorder());

    Border etched = BorderFactory.createEtchedBorder();
    Border titled = BorderFactory.createTitledBorder(etched, "Border types");
    buttonPanel.setBorder(titled);//from  w ww . j  av  a2s  . co m

    setLayout(new GridLayout(2, 1));
    add(buttonPanel);
    add(demoPanel);
}

From source file:MenuLayoutDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.PAGE_AXIS));
    menuBar.add(createMenu("Menu 1"));
    menuBar.add(createMenu("Menu 2"));
    menuBar.add(createMenu("Menu 3"));

    menuBar.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.BLACK));
    return menuBar;
}

From source file:QandE.XMarksTheSpot.java

public XMarksTheSpot() {
    setOpaque(true);//from  w  ww  .ja v a 2 s.  c  om

    //Set the border using either a MatteBorder (standard, used in 
    //Exercise 1) or a StripeBorder (custom, used in Exercise 3).
    //You can find the exercises here:
    //  http://docs.oracle.com/javase/javatutorials/tutorial/uiswing/QandE/questions-ch6.html
    setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.BLACK));
    //setBorder(new StripeBorder());
}