/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package tank; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; class T extends JFrame { small mp = null; // GuanQia gqmb =null; public static void main(String[] args) { T t = new T(); } public T() { mp = new small(); // gqmb = new GuanQia(); // this.add(gqmb); this.add(mp); this.setSize(600,500); this.setLocation(300, 280); this.setDefaultCloseOperation(3); this.setVisible(true); } } public class small extends JPanel { public small(){ } public void paint(Graphics g) { super.paint(g); g.fillRect(0, 0, 500, 400); this.drawTank(0, 0, g); } public void drawTank(int x, int y,Graphics g){ g.setColor(Color.red); g.fill3DRect(x, y, 5, 30, false); g.fill3DRect(x + 15, y, 5, 30, false); g.fill3DRect(x + 5, y + 5, 10, 20, false); g.fillOval(x + 5, y + 10, 10, 10); g.drawLine(x + 10, y + 15, x + 10, y - 5); } }