imagebutton.java
来自「可实现超链接等功能强大的编辑器」· Java 代码 · 共 68 行
JAVA
68 行
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 + =
减小字号Ctrl + -
显示快捷键?