码迷,mamicode.com
首页 > 编程语言 > 详细

Java学习笔记(二)不定时更新

时间:2015-06-19 16:34:34      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

Java语言画图

package cn.witksy.dev;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * Author: Alfred
 * Created: 2015/5/7
 */
public class Main {

    public void run() {
        BufferedImage bufferedImage = new BufferedImage(100,50,BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = bufferedImage.createGraphics();
        g2.setColor(Color.red);
        g2.fillRect(0,0,5,5);
        g2.setColor(Color.blue);
        g2.fillRect(10,20,5,5);
        File outputFile = new File("D:\\dev\\java\\workspace\\draw2dtest\\test.png");
        try {
            ImageIO.write(bufferedImage, "png", outputFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

 

Java学习笔记(二)不定时更新

标签:

原文地址:http://www.cnblogs.com/hdu-2010/p/4588989.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!