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:com.limegroup.gnutella.gui.notify.AnimatedWindow.java

public static void main(String[] args) {
    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(BorderFactory.createLineBorder(Color.black, 2));
    JLabel label = new JLabel("Hello World");
    label.setIcon(UIManager.getIcon("FileView.computerIcon"));
    label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    content.add(label, BorderLayout.CENTER);

    final AnimatedWindow window = new AnimatedWindow(null);
    window.setFinalLocation(new Point(200, 200));
    window.setContentPane(content);/*from ww  w  .  j  a  v a  2  s  .  c om*/

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10));

    JButton button = new JButton("Bottom -> Top");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.BOTTOM_TO_TOP);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    button = new JButton("Top -> Bottom");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.TOP_TO_BOTTOM);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    button = new JButton("Fade");
    buttonPanel.add(button);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            window.setMode(AnimationMode.FADE);
            if (!window.isVisible() || window.isHideAnimationInProgress()) {
                window.doShow();
            } else {
                window.doHide();
            }
        }
    });

    JFrame app = new JFrame("AnimatedWindow Demo");
    app.setContentPane(buttonPanel);
    app.pack();
    app.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    app.setVisible(true);
}

From source file:CheckMenuItem.java

public static void main(String[] args) {
    final JLabel statusbar = new JLabel(" Statusbar");

    JMenuBar menubar = new JMenuBar();
    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    JMenu view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);

    JCheckBoxMenuItem sbar = new JCheckBoxMenuItem("Show StatuBar");
    sbar.setState(true);//from   ww  w.  j ava 2s. c  om

    sbar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            if (statusbar.isVisible()) {
                statusbar.setVisible(false);
            } else {
                statusbar.setVisible(true);
            }
        }
    });

    view.add(sbar);

    menubar.add(file);
    menubar.add(view);

    JFrame f = new JFrame();
    f.setJMenuBar(menubar);
    statusbar.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    f.add(statusbar, BorderLayout.SOUTH);
    f.setSize(360, 250);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

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;/*from w  w  w.j av a  2s  .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;/* w ww .  j ava 2 s  . co  m*/
}

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);
    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);
    return label;
}

From source file:Main.java

public static void addNewLineTo(Container container, int lineHeight) {
    JLabel label = new JLabel();
    label.setPreferredSize(new Dimension(SCREEN_SIZE.width, lineHeight));
    label.setBorder(new LineBorder(Color.BLACK));
    container.add(label);//w  w w . ja v a 2 s  . co  m
}

From source file:Main.java

private static JPanel createLogin() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    JLabel label = new JLabel("login panel.");
    label.setFont(label.getFont().deriveFont(Font.ITALIC, 24f));
    label.setAlignmentX(0.5f);/*from ww  w .j  a v  a2  s.  co  m*/
    label.setBorder(new EmptyBorder(0, 20, 0, 20));
    p.add(Box.createVerticalStrut(36));
    p.add(label);
    p.add(Box.createVerticalStrut(144));
    return p;
}

From source file:ImageLabelExample.java

protected static JLabel makeLabel(int vert, int horiz) {
    JLabel l = new JLabel("Smile", icon, SwingConstants.CENTER);
    l.setVerticalTextPosition(vert);//from  w w  w . j  av  a  2 s.  co m
    l.setHorizontalTextPosition(horiz);
    l.setBorder(BorderFactory.createLineBorder(Color.black));
    return l;
}

From source file:Main.java

public Main(String name) {
    getContentPane().setLayout(new FlowLayout());
    JLabel labelTwo = new JLabel("www.java2s.com");
    labelTwo.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.RAISED, Color.red, Color.black));
    add(labelTwo);/*from  w  w  w .j a v  a2 s  .  c o m*/
}