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

📄 sepbutton.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 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 + -