⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minelineborder.java

📁 用java实现的全真模拟windows下的扫雷程序。不过目前实现以button方式实现。改进可以考虑以位图形式实现
💻 JAVA
字号:
/*
 * MineLineBorder.java 1.0 2003-6-15
 *
 * Copyleft (c) 2003 RatKing.
 */

package jmine;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;

/**
 * 用于地雷游戏中,在按钮的上侧和左侧画灰色线形镶边
 *
 * @author <a href="ratking@ynet.com">RatKing</a>
 * @version 1.0
 */
public class MineLineBorder extends AbstractBorder {
    private static Border grayLineBorder;

    private MineLineBorder() {
    }

    /** 获得线宽为1的灰色线形镶边 */
    public static Border createBorder() {
        if (grayLineBorder == null) {
            grayLineBorder = new MineLineBorder();
        }
        return grayLineBorder;
    }

    /**
     * Paints the border for the specified component with the
     * specified position and size.
     * @param c the component for which this border is being painted
     * @param g the paint graphics
     * @param x the x position of the painted border
     * @param y the y position of the painted border
     * @param width the width of the painted border
     * @param height the height of the painted border
     */
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
        Color oldColor = g.getColor();
        g.setColor(Color.gray);
        g.drawLine(x, y, x+width-1, y);
        g.drawLine(x, y, x, y+height-1);
        g.setColor(oldColor);
    }

    /**
     * Returns the insets of the border.
     * @param c the component for which this border insets value applies
     */
    public Insets getBorderInsets(Component c) {
        return new Insets(1, 1, 0, 0);
    }

    /**
     * Reinitialize the insets parameter with this Border's current Insets.
     * @param c the component for which this border insets value applies
     * @param insets the object to be reinitialized
     */
    public Insets getBorderInsets(Component c, Insets insets) {
        insets.left = insets.top = 1;
        insets.right = insets.bottom = 0;
        return insets;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -