I have a program that fires a gun, tell me how to make it so that when the button is pressed, the gun fired more than once?
package gun; import java.applet.*; import java.awt.*; import java.util.logging.Level; import java.util.logging.Logger; public class Gun extends Applet implements Runnable { static final String Set = "Pow"; int x0 = 275, y0 = 390, k = 1, v0 = 85, x, y; double time = 0, alfa0, alfa; Button btn; Color col, col1, col2, col3, col4; Image img, img2; Font font; Thread t; @Override public void init() { setLayout(new BorderLayout()); btn = new Button(Set); add("North", btn); font = new Font("Arial", Font.BOLD + Font.ITALIC, 48); col = new Color(69, 139, 0); col1 = new Color(139, 71, 38); col2 = new Color(71, 60, 139); col3 = new Color(0, 139, 0); col4 = new Color(65, 66, 71); img = getImage(getDocumentBase(), "1.png"); img2 = getImage(getDocumentBase(), "2.png"); } @Override public void run() { while (true) { time += 0.1; alfa0 = 45; alfa = alfa0 * 3.14 / 180; x = (int) (x0 + v0 * time * Math.cos(alfa)); y = (int) (y0 - v0 * time * Math.sin(alfa) + 9.8 * (Math.pow(time, 2)) / 2); repaint(); try { Thread.sleep(10); } catch (InterruptedException ex) { Logger.getLogger(Gun.class.getName()).log(Level.SEVERE, null, ex); } } } @Override public void paint(Graphics g) { if ((x > 1000) && (x < 1230) && (y > 380) && (y < 620)) { g.drawImage(img2, 20, 378, this); } g.drawImage(img2, 20, 378, this); //cvet fona setBackground(new Color(238, 232, 170)); //zemlya i cel' g.setColor(col); g.fillRect(0, 500, 2000, 800); g.drawImage(img, 1000, 380, this); g.setColor(col1); g.fillRect(1200, 250, 35, 250); g.setColor(col3); g.fillOval(1155, 200, 130, 150); g.setColor(col2); int[] X = {40, 220, 230, 50, 40}; int[] Y = {430, 390, 430, 460, 430}; g.fillPolygon(X, Y, X.length); //bolwoi krug g.setColor(Color.GRAY); g.fillOval(60, 420, 80, 80); //srednii g.setColor(col1); g.fillOval(70, 430, 60, 60); //malenkii g.setColor(Color.GRAY); g.fillOval(90, 450, 20, 20); //polosi g.setColor(Color.GRAY); g.drawLine(58, 458, 138, 458); g.setColor(Color.GRAY); g.drawLine(59, 459, 139, 459); g.setColor(Color.GRAY); g.drawLine(60, 460, 140, 460); g.setColor(Color.GRAY); g.drawLine(59, 461, 139, 461); g.setColor(Color.GRAY); g.drawLine(58, 462, 138, 462); //verticalnie polosi g.setColor(Color.GRAY); g.drawLine(99, 419, 99, 499); g.setColor(Color.GRAY); g.drawLine(100, 420, 100, 500); g.setColor(Color.GRAY); g.drawLine(101, 419, 101, 501); //iskra g.setColor(Color.ORANGE); int[] X1 = {220, 240, 225, 233, 228, 240, 231, 238, 230, 242, 230}; int[] Y1 = {390, 380, 393, 395, 400, 402, 407, 415, 417, 431, 430}; g.fillPolygon(X1, Y1, X1.length); //yadra g.setColor(Color.BLACK); g.fillOval(150, 470, 30, 30); g.setColor(Color.BLACK); g.fillOval(185, 470, 30, 30); g.setColor(Color.BLACK); g.fillOval(168, 447, 30, 30); g.setColor(col4); g.fillOval(x, y, 15, 15); } @Override public boolean handleEvent(Event evt) { switch (evt.id) { case Event.ACTION_EVENT: { if ((evt.arg == Set) && (k == 2)) { k = 1; } else if ((evt.arg == Set) && (k == 1)) { k = 2; t = new Thread(this); t.start(); repaint(); } else { return false; } } default: return false; } } }