Example usage for javax.swing BorderFactory createEtchedBorder

List of usage examples for javax.swing BorderFactory createEtchedBorder

Introduction

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

Prototype

public static Border createEtchedBorder() 

Source Link

Document

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Usage

From source file:Main.java

public static void main(String[] argv) {

    EtchedBorder etchedBorder = (EtchedBorder) BorderFactory.createEtchedBorder();
    JLabel component = new JLabel("label");
    component.setBorder(etchedBorder);//from  ww w.  jav  a 2s .  c o  m

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Table Title",
            TitledBorder.CENTER, TitledBorder.TOP));

    JTable table = new JTable(3, 3);

    panel.add(new JScrollPane(table));

    frame.add(panel);/*  www  .  j  a  v  a 2 s.c o  m*/
    frame.pack();
    frame.setVisible(true);
}

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  w w  . j  a  v  a 2 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:Main.java

public static JPanel placeInTitledEtchedJPanel(Component c, String title, Color titleColor) {
    JPanel parent = new JPanel(new BorderLayout());
    parent.add(c, BorderLayout.CENTER);
    TitledBorder tb = new TitledBorder(title);
    tb.setBorder(BorderFactory.createEtchedBorder());
    tb.setTitleColor(titleColor);//from w  w w  .  ja v a2  s.c o m
    parent.setBorder(tb);
    return parent;
}

From source file:JListBackground.java

public static void addComponentsToPane(Container pane) {
    String[] bruteForceCode = { "int count = 0", "int m = mPattern.length();", "int n = mSource .length();",
            "outer:", " ++count;", " }", " return count;", "}" };
    JList list = new JList(bruteForceCode);
    Border etch = BorderFactory.createEtchedBorder();
    list.setBorder(BorderFactory.createTitledBorder(etch, "Brute Force Code"));
    JPanel listPanel = new JPanel();
    listPanel.add(list);/*from w  w w.  j a  v a2 s. c  om*/
    listPanel.setBackground(lightBlue);
    list.setBackground(lightBlue);

    pane.add(listPanel, BorderLayout.CENTER);
    pane.setBackground(lightBlue);
}

From source file:Main.java

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

    add(labelTwo);//from  w  ww  . j a 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:EtchedBorderBorderFactory.java

public EtchedBorderBorderFactory() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    JLabel label;// w  w  w  . j  a  va  2 s.  co m

    label = new JLabel("Etched");
    label.setBorder(BorderFactory.createEtchedBorder());
    panel.add(label);
    getContentPane().add(panel);
    pack();
}

From source file:Main.java

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

    add(labelTwo);/*from w  ww . jav  a  2  s. c om*/

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.ABOVE_BOTTOM,
            TitledBorder.BOTTOM, new Font("font name", Font.BOLD, 19)));
    add(labelFour);

}

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 va2 s .  c  om

    JLabel labelFour = new JLabel("TitledBorder");
    labelFour.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink), "Title", TitledBorder.ABOVE_BOTTOM,
            TitledBorder.BOTTOM, new Font("font name", Font.BOLD, 19), Color.BLACK));
    add(labelFour);

}

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 ww w . j  a v  a 2s. 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);
        }
    });
}