Raised and Lowered EtchedBorder : EtchedBorder « Swing « Java Tutorial






Raised and Lowered EtchedBorder
import java.awt.Container;
import java.awt.GridLayout;

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

public class AnEtchedBorder {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Etched Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED);
    Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED);
    JButton raisedButton = new JButton("Raised");
    raisedButton.setBorder(raisedBorder);
    
    JButton loweredButton = new JButton("Lowered");
    loweredButton.setBorder(loweredBorder);
    
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2, 5, 5));
    contentPane.add(raisedButton);
    contentPane.add(loweredButton);
    frame.setSize(300, 100);
    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