EtchedBorder : EtchedBorder « Swing « Java Tutorial






  1. An etched border produces either an etched-in or etched-out effect.
  2. You can specify the type of etching using the field LOWERED or RAISED.
  3. By default, the etched border is of type etched-in.
public EtchedBorder()
Border etchedBorder = new EtchedBorder();


public EtchedBorder(int etchType)
Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED);


public EtchedBorder(Color highlight, Color shadow)
Border etchedBorder = new EtchedBorder(Color.RED, Color.PINK);


public EtchedBorder(int etchType, Color highlight, Color shadow)
Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, Color.RED, Color.PINK);


public static Border createEtchedBorder()
Border etchedBorder = BorderFactory.createEtchedBorder();


public static Border createEtchedBorder(Color highlight, Color shadow)
Border etchedBorder = BorderFactory.createEtchedBorder(Color.RED, Color.PINK);


public static Border createEtchedBorder(EtchedBorder.RAISED)
Border etchedBorder = BorderFactory.createEtchedBorder(Color.RED, Color.PINK);


public static Border createEtchedBorder(int type, Color highlight, Color shadow)
Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED, Color.RED, Color.PINK);
EtchedBorder
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class EtchedBorderBorderFactory extends JFrame {

  public EtchedBorderBorderFactory() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    JLabel label;

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

  public static void main(String[] args) {
    EtchedBorderBorderFactory s = new EtchedBorderBorderFactory();
    s.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