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

📄 separator.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
字号:
/*
    $Author: $
    $Date: $
    $Revision: $
    $NoKeywords: $
*/
package jp.co.ntl.awt;

import java.awt.Graphics;
import java.awt.Color;

public class Separator {
	public static final int VERTICAL = 0;
	public static final int HORIZONTAL = 1; 
    private int x;
    private int y;
    private int length;
    private int direction;
    
    public Separator(int x, int y, int length) {
        this.x = x;
        this.y = y;
        this.length = length;
        direction = HORIZONTAL;
    }
    
    public Separator(int x, int y) {
    	this(x, y, 100);
    }
    
    public void setSize(int x, int y, int length) {
    	this.x = x;
    	this.y = y;
    	this.length = length;
    }
    
    public void setLength(int length) {
    	this.length = length;
    }
    
    public void setDirection(int direction) {
    	this.direction = direction;
    }
    
    public void draw(Graphics g, Color color) {
    	if (direction == HORIZONTAL) {
			g.setColor(Color.white);
			g.drawLine(x + 1, y + 1, x + 1 + length, y + 1);
			g.setColor(color);
			g.drawLine(x, y, x + length, y);   		
    	} else if (direction == VERTICAL) {
			g.setColor(Color.white);
			g.drawLine(x + 1, y - 1, x + 1, y - 1 + length);
			//g.setColor(color);
			g.drawLine(x, y, x, y + length);   	    		
    	} else {
    		throw new IllegalArgumentException("wrong argument direction");
    	}
    }
}

⌨️ 快捷键说明

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