Source Code : Solid border button border 3D border

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Solid border button border 3D border

Solid border button border 3D border
   
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;

public class SolidBorder implements Border {
  protected Color topColor = Color.white;

  protected Color bottomColor = Color.gray;

  public SolidBorder() {
  }


  public Insets getBorderInsets(Component c) {
    return new Insets(2, 2, 2, 2);
  }

  public boolean isBorderOpaque() {
    return true;
  }

  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    width--;
    height--;
    g.setColor(topColor);
    g.drawLine(x, y + height, x, y);
    g.drawLine(x , y, x + width , y);

    g.setColor(bottomColor);
    g.drawLine(x + width, y, x + width, y + height);
    g.drawLine(x , y + height, x + width, y + height);
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame("Custom Border: SolidBorder");
    JLabel label = new JLabel("SolidBorder");
    ((JPanel) frame.getContentPane()).setBorder(new CompoundBorder(
        new EmptyBorder(10, 10, 10, 10), new SolidBorder()));
    frame.getContentPane().add(label);
    frame.setBounds(0, 0, 300, 150);
    frame.setVisible(true);
  }
}


           
         
    
    
  

Thank with us