?? minelineborder.java
字號(hào):
/*
* 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;
/**
* 用于地雷游戲中,在按鈕的上側(cè)和左側(cè)畫灰色線形鑲邊
*
* @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;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -