LineBorder: color and width : LineBorder « Swing « Java Tutorial






LineBorder: color and width
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;

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

public class ALineBorder {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Line Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    Border thinBorder = LineBorder.createBlackLineBorder();
    Border thickBorder = new LineBorder(Color.WHITE, 12);
    Border roundedBorder = new LineBorder(Color.BLACK, 2, true);
    
    JButton thinButton = new JButton("1 Pixel");
    thinButton.setBorder(thinBorder);
    
    JButton thickButton = new JButton("12 Pixel");
    thickButton.setBorder(thickBorder);
    
    JButton roundedButton = new JButton("Rounded 2 Pixel");
    roundedButton.setBorder(roundedBorder);
    
    Container contentPane = frame.getContentPane();
    contentPane.add(thinButton, BorderLayout.NORTH);
    contentPane.add(thickButton, BorderLayout.CENTER);
    contentPane.add(roundedButton, BorderLayout.SOUTH);
    frame.pack();
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
  }
}








14.100.LineBorder
14.100.1.LineBorder Class
14.100.2.LineBorder: color and widthLineBorder: color and width
14.100.3.Creating and Setting a line Border from BorderFactory