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

📄 imagebutton.java

📁 可实现超链接等功能强大的编辑器
💻 JAVA
字号:
package com.cwq.htmltoolbar;


import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;

public abstract class ImageButton extends ImageLabel implements MouseListener {
	
	private Icon icon0 = null;
	private Icon icon1 = null;
	private Icon icon2 = null;

	public ImageButton(String iconFile) {
		this(iconFile, null, null);
		// TODO Auto-generated constructor stub
	}
	
	public ImageButton(String iconFile, String iconFile1) {
		this(iconFile, iconFile1, null);
		// TODO Auto-generated constructor stub
	}
	
	public ImageButton(String iconFile, String iconFile1, String iconFile2) {
		super(iconFile);
		try { this.icon0 = new ImageIcon(new URL(HtmlToolBar.imagepath.concat(iconFile))); } catch(Exception ex) {}
		try { this.icon1 = new ImageIcon(new URL(HtmlToolBar.imagepath.concat(iconFile))); } catch(Exception ex) { }
		try { this.icon2 = new ImageIcon(new URL(HtmlToolBar.imagepath.concat(iconFile2))); } catch(Exception ex) {}
		this.addMouseListener(this);
		// TODO Auto-generated constructor stub
	}
	
	abstract public void mouseClicked(MouseEvent arg0);

	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		if(icon1 != null) {
			super.setIcon(icon1);
		}
	}

	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		super.setIcon(icon0);
	}

	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		if(icon2 != null) {
			super.setIcon(icon2);
		}
		else if(icon1 != null)
			super.setIcon(icon1);
		else
			;
	}

	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		super.setIcon(icon0);
	}

}

⌨️ 快捷键说明

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