draw Border White - Java Swing

Java examples for Swing:Border

Description

draw Border White

Demo Code


//package com.java2s;
import java.awt.Color;
import java.awt.Graphics2D;
import javax.swing.JComponent;

public class Main {
    public static void drawBorderWhite(Graphics2D g, JComponent focusOwner,
            JComponent area) {//ww  w  .  j  a v a2s  . c  om

        g.setColor(new Color(255, 255, 255));
        g.drawRect(0, 0, area.getWidth() - 1, area.getHeight() - 1);
        g.drawRect(1, 1, area.getWidth() - 3, area.getHeight() - 3);

        if (focusOwner != null && focusOwner.isFocusOwner()) {
            g.setColor(new Color(240, 240, 240));
            g.drawRect(0, 0, area.getWidth() - 1, area.getHeight() - 1);
            g.drawRect(1, 1, area.getWidth() - 3, area.getHeight() - 3);
        }

    }
}

Related Tutorials