CompoundBorder with double line borders and Lowered Bevel Border : CompoundBorder « Swing « Java Tutorial






CompoundBorder with double line borders and Lowered Bevel Border
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;

public class CompoundBorderLabel extends JFrame {
  JLabel label = new JLabel("A label with some borders");

  public CompoundBorderLabel() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border border1 = new CompoundBorder(LineBorder.createBlackLineBorder(),
        BorderFactory.createLineBorder(Color.red, 20));

    Border border2 = new CompoundBorder(border1, BorderFactory
        .createLoweredBevelBorder());

    label.setBorder(border2);
    getContentPane().add(label, BorderLayout.CENTER);
    pack();
  }

  public static void main(String arg[]) {
    CompoundBorderLabel m = new CompoundBorderLabel();
    m.setVisible(true);
  }
}








14.104.CompoundBorder
14.104.1.CompoundBorder: to combine borders before associating them with a component.CompoundBorder: to combine borders before associating them with a component.
14.104.2.Creating CompoundBorder with LineBorderCreating CompoundBorder with LineBorder
14.104.3.CompoundBorder with double line borders and Lowered Bevel BorderCompoundBorder with double line borders and Lowered Bevel Border