JAVA绘制图片
package test.tank;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Test1_1 extends JFrame{
MyPanel mp=null;
public static void main(String[] args)
{
Test1_1 tes=new Test1_1();
}
public Test1_1()
{
mp=new MyPanel();
this.setSize(300, 300);
this.add(mp);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class MyPanel extends JPanel
{
public void paint(Graphics g)
{
super.paint(g);
Image im=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/logo.jpg"));
g.drawImage(im, 50, 50, 250, 250, this);
}
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20181219103959276.png)