Creating EtchedBorder with its Constructor : EtchedBorder « Swing « Java Tutorial






Creating EtchedBorder with its Constructor
import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;

public class EtchedBorderSample {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Sample Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, Color.RED, Color.PINK);
    
    JLabel aLabel = new JLabel("Bevel");
    aLabel.setBorder(etchedBorder);
    aLabel.setHorizontalAlignment(JLabel.CENTER);

    frame.add(aLabel);
    frame.setSize(400, 200);
    frame.setVisible(true);
  }
}








14.106.EtchedBorder
14.106.1.EtchedBorderEtchedBorder
14.106.2.Creating EtchedBorder with its ConstructorCreating EtchedBorder with its Constructor
14.106.3.Raised and Lowered EtchedBorderRaised and Lowered EtchedBorder
14.106.4.Creating and Setting an EtchedBorder from BorderFactory