关于创建图标的程序。新手求教

疯子霆 2018-12-24 02:31:03
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;

import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

public class DrawIcon implements Icon {
private int width;
private int height;
public int getIconHeight(){
return this.height;
}
public int getIconWidth(){
return this.width;
}
public DrawIcon(int width,int height){
this.width=width;
this.height=height;
}

public void paintIcon(Component arg0,Graphics arg1,int x,int y){
arg1.fillOval(x, y, width, height);
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
DrawIcon icon=new DrawIcon(15,15);
JLabel j=new JLabel("测试",icon,SwingConstants.CENTER);
JFrame jf=new JFrame();
Container c=jf.getContentPane();
// 后边再怎么写? 调用DrawIcon 类 实现程序。。不会了。

}

}
...全文
22 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧