imagelabel.java

来自「可实现超链接等功能强大的编辑器」· Java 代码 · 共 39 行

JAVA
39
字号
package com.cwq.htmltoolbar;


import java.awt.Dimension;
import java.net.MalformedURLException;
import java.net.URL;

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

public class ImageLabel extends JLabel {
	
	public ImageLabel(String iconFile) {
		super("");
		try {
			this.setIcon(new ImageIcon(new URL(HtmlToolBar.imagepath.concat(iconFile))));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		init();
	}
	
	public ImageLabel(Icon icon) {
		super("");
		this.setIcon(icon);
		init();
	}
	
	private void init() {
		Dimension d = new Dimension(this.getIcon().getIconWidth(), this.getIcon().getIconHeight());
		this.setSize(d);
		this.setPreferredSize(d);
		this.setBorder(null);
	}

}

⌨️ 快捷键说明

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