アットウィキロゴ

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

public class pro extends JFrame{
  public static void main(String[] args){
    pro test = new pro();

    test.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e){System.exit(0);}
    });

    test.setBounds( 0, 0, 500, 500);
    test.setVisible(true);
  }

  public void paint(Graphics g){
    Graphics2D g2 = (Graphics2D)g;

    BufferedImage readImage = null;
    

    if (readImage == null){
      readImage = new BufferedImage(getWidth(), getHeight(),
        BufferedImage.TYPE_INT_BGR);
    }

    Graphics2D off = readImage.createGraphics();

    off.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);

BasicStroke wideStroke = new BasicStroke(4.0f);
    off.setStroke(wideStroke);

    off.setPaint(Color.white);
    off.drawLine(0, 0, 50, 50);

    
    if (readImage != null){g2.drawImage(readImage, 100, 100, this);}

    try {
      boolean result =
       ImageIO.write(readImage, "jpg", new File("sam.jpg"));
    } catch (Exception e) {
        e.printStackTrace();
    }
  }
}
最終更新:2010年11月04日 04:38