java中的icon是什么啊?

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
mengvlog 阅读 6 次 更新于 2025-07-19 05:05:07 我来答关注问题0
  • 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 setIcon应该怎么用?

    \x0d\x0a在API中找到了这五个,但是我们一般用的就是setIcon(Icon),其中Icon类是接口,无法创建实例,所以这里的Icon一般用实现了Icon接口的ImageIcon类来代替。\x0d\x0a举个例子:\x0d\x0a假如你的同一个目录下有一个1.png的图片,给JLabel设置图标就可以这样:\x0d\x0aJLabel label=ne...

  • 设置图标属性。在API中找到了这五个,但是我们一般用的就是setIcon(Icon),其中Icon类是接口,无法创建实例,所以这里的Icon一般用实现了Icon接口的ImageIcon类来代替。举个例子:假如你的同一个目录下有一个1.png的图片,给JLabel设置图标就可以这样:JLabel label=new JLabel();ImageIcon icon=new Im...

  • ①简单性:Java中由JVM来操作内存,所有的Javaicon程序都运行在Java虚拟机当中(JVM是用c+电脑 +写好的一个虚拟电脑)。②面向对象:Java提供了封装,继承,多态等面向对像的机制。③健壮性:Java引入了自动垃圾回收机制(GC),在特定时机是释放垃圾数据。④支持多线程icon:支持多个线程同时并发访问,...

  • 今天无聊翻了下java swing和awt的书看了下,搞了个测试窗口,又改了下icon图标,然后也碰到这个问题。以下是资料:在JDK1.4以前,我们只有一种方式来去掉窗口的标题栏,那就是直接使用JWindow,用JWindow来代替JFrame使用。但用过JWindow的人一定知道,JWindow在操作系统的任务栏是不可见的,这样我们就...

檬味博客在线解答立即免费咨询

Java相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部