Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

In this page you can find the example usage for javax.swing JLabel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:Main.java

public Main() {
    setLayout(null);/*from  w w  w.  j  a  va 2s  . c  om*/
    setSize(400, 400);

    panel1.setLayout(null);
    panel1.setBounds(0, 0, 400, 400);
    add(panel1);

    JLabel label1 = new JLabel("a label");
    label1.setBounds(15, 15, 150, 30);
    label1.setBorder(new BevelBorder(BevelBorder.RAISED));
    panel1.add(label1);

    JLabel label2 = new JLabel("a label");
    label2.setBounds(100, 100, 150, 30);
    label2.setBorder(new BevelBorder(BevelBorder.RAISED));
    panel1.add(label2);

    JLabel label3 = new JLabel("a label");
    label3.setBounds(200, 200, 150, 30);
    label3.setBorder(new BevelBorder(BevelBorder.RAISED));
    panel1.add(label3);

}

From source file:Main.java

private JPanel createComboLabelPanel(int index, JComboBox<ComboColor> combo) {
    JPanel panel = new JPanel();
    JLabel label = new JLabel(SIGNAL + " " + index);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    label.setOpaque(true);/*from   w ww  . j a v  a  2s  .c om*/
    combo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            ComboColor cColor = (ComboColor) combo.getSelectedItem();
            label.setBackground(cColor.getColor());
        }
    });

    panel.add(label);
    panel.add(combo);
    return panel;
}

From source file:Main.java

private JPanel createGridPanel() {
    int rows = 5;
    int cols = 5;
    JPanel gridPanel = new JPanel(new GridLayout(rows, cols));
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            JLabel label = new JLabel(String.format("[%d, %d]", i, j), SwingConstants.CENTER);
            label.setBorder(BorderFactory.createEtchedBorder());
            gridPanel.add(label);/*w  w  w  .  j a v  a  2s  . com*/
        }
    }
    return gridPanel;
}

From source file:SizingSamples.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected,
            cellHasFocus);//from   w w w.j av a 2s.  c om
    renderer.setBorder(cellHasFocus ? focusBorder : noFocusBorder);
    return renderer;
}

From source file:TitledExample.java

public TitledExample() {
    super(true);//w  w  w  .  j  a  v a2  s.c  o m

    this.setLayout(new GridLayout(1, 1, 5, 5));

    JLabel label = new JLabel("Titled Border");
    label.setHorizontalAlignment(JLabel.CENTER);

    TitledBorder titled = new TitledBorder("Title");
    label.setBorder(titled);

    add(label);
}

From source file:hermes.browser.dialog.BeanPropertyPanel.java

protected JComponent createNorthComponent() {
    JLabel classNameLabel = new JLabel("Class: " + bean.getClass().getName());
    classNameLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    return classNameLabel;
}

From source file:Main.java

private ListCellRenderer<? super String> getRenderer() {
    return new DefaultListCellRenderer() {
        @Override// w w w .  j  a va 2 s.c o  m
        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:RoundedLineBorder.java

public RoundedLineBorder() {
    super(true);//  w w w . j a  v  a 2s . co m
    setLayout(new BorderLayout());

    JLabel label = new JLabel("Rounded Corners");

    label.setHorizontalAlignment(JLabel.CENTER);

    LineBorder line = new LineBorder(Color.blue, 2, true);

    label.setBorder(line);

    add(label, BorderLayout.CENTER);
}

From source file:com.opendoorlogistics.studio.tables.grid.HeaderCellRenderer.java

/**
 * /*  www .  j  ava  2  s.c  o m*/
 */
protected void initLabel(JLabel label) {
    label.setOpaque(true);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
}

From source file:com.game.ui.views.UserDialog.java

public UserDialog(String message, JFrame frame) {
    setLayout(new BorderLayout(5, 5));
    setModalityType(ModalityType.APPLICATION_MODAL);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setResizable(false);//from   www .  j  a  v a  2s .  c o m
    ImageIcon icon = null;
    try {
        icon = GameUtils.shrinkImage("warning.gif", 30, 30);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JPanel panel = new JPanel();
    JLabel label = new JLabel(icon);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    label.setText(message);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    label.setHorizontalAlignment(0);
    panel.add(label);
    add(panel, BorderLayout.NORTH);
    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
    txt = new JTextField();
    txt.setPreferredSize(new Dimension(150, 30));
    txt.setAlignmentX(.5f);
    txt.setMaximumSize(new Dimension(150, 30));
    contentPanel.add(txt);
    contentPanel.add(Box.createVerticalStrut(10));
    JButton btn = new JButton("Submit.");
    btn.setAlignmentX(.5f);
    btn.setPreferredSize(new Dimension(50, 25));
    btn.addActionListener(this);
    validationMess = new JLabel("All fields are mandatory");
    validationMess.setVisible(false);
    validationMess.setForeground(Color.red);
    validationMess.setAlignmentX(.5f);
    contentPanel.add(btn);
    contentPanel.add(Box.createVerticalStrut(10));
    contentPanel.add(validationMess);
    contentPanel.add(Box.createVerticalGlue());
    add(contentPanel, BorderLayout.CENTER);
    pack();
    setSize(new Dimension(300, 200));
    setLocationRelativeTo(frame);
    setVisible(true);
}