java中的icon是属于接口类,主要设置窗口图标,实例如下:package com.han;import java.awt.*;import javax.swing.*;/** * This example shows the drawing of an icon using the Icon interface * for the JLable component. * @author han * */public class DrawIcon implements Icon{//该类...
java中的icon是什么啊?
ICON是接口,ImageIcon是实现了该接口的类 作用嘛,多数用在编写界面中,你可以在Button或是JButton里加载这种小图标2014-06-29
java中的icon是属于接口类,主要设置窗口图标,实例如下:
package com.han;import java.awt.*;import javax.swing.*;/** * This example shows the drawing of an icon using the Icon interface * for the JLable component. * @author han * */public class DrawIcon implements Icon{//该类实现该接口iconprivate int width;private int height;@Overridepublic int getIconHeight(){return this.height;}@Overridepublic int getIconWidth(){return this.width;}@Overridepublic void paintIcon(Component c, Graphics g, int x, int y){g.setColor(Color.red);g.fillOval(x, y, width, height);}/*the construct function*/public DrawIcon(int width, int height){this.width=width;this.height=height;} public static void main(String[] args){ DrawIcon icon=new DrawIcon(15,15); JLabel jl=new JLabel("测试",icon,SwingConstants.CENTER); JFrame jf=new JFrame(); Container c=jf.getContentPane(); c.add(jl); jf.setVisible(true); jf.setSize(300,300); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }}2015-11-05
图标对象,一般写在按钮上2015-09-28
icon一般是图标,不知道你这个icon是个class还是图标文件?java语言本身没有icon基本类型,问得有点简略哦2015-09-16