?? sepbutton.java
字號:
/*
$Author: Shigura $
$Date: 01/05/31 15:49 $
$Revision: 6 $
$NoKeywords: $
*/
//
// Image Button for Separate Ink
//
package jp.co.ntl.swing.ext;
import java.awt.*;
public class SepButton extends GroupButton
{
/**
*
*/
private static final long serialVersionUID = 1L;
Image image;
Image imagePushed;
boolean newline;
Color bg;
int width, height;
int imgX, imgY;
int imgWidth, imgHeight;
boolean border;
boolean move;
public SepButton(int width, int height, ButtonGroup group)
{
this(null, null, width, height, group);
}
public SepButton(int width, int height)
{
this(null, null, width, height, null);
}
public SepButton(Image image, Image imagePushed, int width, int height, ButtonGroup group)
{
super(group);
setSize(width, height);
bg = new Color(200, 200, 200);
this.image = image;
this.imagePushed = imagePushed;
this.width = width;
this.height = height;
}
public SepButton(Image image, Image imagePushed, int width, int height)
{
this(image, imagePushed, width, height, null);
}
public SepButton(Image image, int width, int height, ButtonGroup group)
{
this(image, image, width, height, group);
}
public SepButton(Image image, int width, int height)
{
this(image, image, width, height, null);
}
public void set3DBorder(boolean border) {
this.border = border;
}
public void setMove(boolean move) {
this.move = move;
}
public void renewalImage(Image image)
{
this.image = image;
this.imagePushed = image;
repaint();
}
public Dimension getPreferredSize() {
return new Dimension(width, height);
}
public Dimension getMinimumSize() {
return getPreferredSize();
}
//
// Paint
//
/*
public void update(Graphics g)
{
paint(g);
}*/
public void paintComponent(Graphics g)
{
g.setColor(bg);
imgX = 0;
imgY = 0;
imgWidth = width;
imgHeight = height;
if (pushed) {
if (border) {
g.fill3DRect(0, 0, width, height, false);
}
if (imagePushed != null) {
if (move) {
g.drawImage(imagePushed, imgX + 1, imgY + 1, imgWidth, imgHeight, this);
} else {
g.drawImage(imagePushed, imgX, imgY, imgWidth, imgHeight, this);
}
}
} else {
if (border) {
g.fill3DRect(0, 0, width, height, true);
}
if (image != null) {
g.drawImage(image, imgX, imgY, imgWidth, imgHeight, this);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -