AWT的Graphics

黎某人 2009-08-05 08:48:10
在窗体重绘的时候 void paint(Graphics g)中可以绘制图形 而且这个g在绘制完窗体后就用变成空的引用

问题来了 有时候不需要在窗体一开始绘制就绘制图形 而是按需要来绘制图片 形状等

怎么能在其他的地方 比如Frame子类中自定义的其他方法中 绘制图形 除了用Canvas画图
...全文
97 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
999朵玫瑰 2009-08-06
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zl3450341 的回复:]
Java code
BufferedImage image=new BufferedImage(100,100,1);
Graphics g=image.getGraphics();

学习了
黎某人 2009-08-06
  • 打赏
  • 举报
回复
BufferedImage image=new BufferedImage(100,100,1);
请问这个是干什么用的
我继承Frame后 用Graphics g=this.getGraphics(); 行不行
老张-AI 2009-08-05
  • 打赏
  • 举报
回复

BufferedImage image=new BufferedImage(100,100,1);
Graphics g=image.getGraphics();


学习了
猿敲月下码 2009-08-05
  • 打赏
  • 举报
回复
可以这样:
BufferedImage image=new BufferedImage(100,100,1);
Graphics g=image.getGraphics();

62,621

社区成员

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

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