【java版坦克大战---准备篇】 java 绘图

java

要写坦克大战当然要先画出坦克。java画图是基础。

package com.game;

import java.awt.*;

import javax.swing.*;

public class Pro_1 extends JFrame {

public static MyPanel mp=null;

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

Pro_1 pro_1 = new Pro_1();

pro_1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

mp = new MyPanel();

pro_1.add(mp);

pro_1.setSize(new Dimension(400,300));

pro_1.setTitle("Demo");

pro_1.setVisible(true);

}

}

class MyPanel extends Panel{

public void paint(Graphics g){

super.paint(g);

g.drawOval(10, 10, 50, 50);

g.setColor(Color.blue);

g.setFont(new Font("华文彩云1",Font.BOLD,40));

g.drawImage(Toolkit.getDefaultToolkit().getImage("./loginbtn.jpg"), 60, 60, 85, 32,this);

g.drawString("hi,你好",40,50);

}

}

 

以上是 【java版坦克大战---准备篇】 java 绘图 的全部内容, 来源链接: utcz.com/z/395148.html

回到顶部