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

📄 separatorcomp.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
字号:
package jp.co.ntl.swing;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JComponent;

import jp.co.ntl.awt.Separator;

public class SeparatorComp extends JComponent {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7355803077589809714L;
	public final static int VERTICAL = Separator.VERTICAL;
	public final static int HORIZONTAL = Separator.HORIZONTAL;
	
	private Separator sep;
	private int direction;
	
	public SeparatorComp() {
		sep = new Separator(0, 0, 0);
		this.direction = Separator.HORIZONTAL;
		sep.setDirection(direction);
	}

	public SeparatorComp(int direction) {
		sep = new Separator(0, 0, 0);
		this.direction = direction;
		sep.setDirection(direction);
	}
	
	public void setBounds(int x, int y, int width, int height) {
		super.setBounds(x, y, width, height);
		setSeparatorSize(width, height);	
	}
	
	public void setSize(int x, int y) {
		super.setSize(x, y);	
		setSeparatorSize(x, y);	
	}
	
	public void setSize(Dimension d) {
		super.setSize(d);
		setSeparatorSize(d.getSize().width, d.getSize().height);	
	}
	
	public void paint(Graphics g) {
		if (sep == null) {
			return;
		}
		
		sep.draw(g, getBackground().darker());
	}
	
	private void setSeparatorSize(int width, int height) {
		if (direction == HORIZONTAL) {
			sep.setSize(0, height / 2, width);
		} else {
			sep.setSize(width / 2, 0, height);
		}		
	}
}

⌨️ 快捷键说明

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