title: Made a "virus", need tips
body: <p>First of all, it's not really a virus that is used to spy, or steal bank accounts. I don't even know if it's a virus at all. I only made it to troll friends/people I know, and practice my programming skills. I will show you the code, then I will try to explain it a bit;</p>
  
  <pre><code>package pracatice;
  
  import java.awt.event.*;
  
  import javax.swing.*;
  
  public class practice extends JFrame 
  {
      public static boolean bool = true;
      public static int x = 0;
      public static int y = 0;
      public static int num = 0;
      public static TimerClass tc = new TimerClass();
      public static Timer timer = new Timer(30, tc);
      public JPanel panel = new JPanel();
      public JButton btn = new JButton("press");
  
      public practice()
      {
          setSize(100,100);
          setTitle("Test");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
          setPanel();
          setVisible(true);   
      }
      public void setPanel()
      {
          btn.addActionListener(new listener());
          panel.add(btn);
  
          add(panel);
      }
  
      public class listener implements ActionListener
      {
          public void actionPerformed(ActionEvent e)
      {
          num = 0;
          timer.start();
      }
  }
  
      public static class TimerClass implements ActionListener
      {
          public void actionPerformed(ActionEvent e)
          {
              do
              {
  
              num++;
              JOptionPane optionPane = new JOptionPane("PC afected by virus");
              JDialog dialog = optionPane.createDialog(null, "Virus");
              dialog.setModal(false);
              dialog.setLocation(x, y);
              dialog.show();
              updateCordinates();
              }while(bool == true);
          }
      }
  
      public static void updateCordinates()
      {
          if(x != 1100)
              x += 100;
          else if(x == 1100)
          {
              x = 0;
              y += 50;
          }
          if(y == 650)
             y =0;
  
  
      }
       public static void main(String[] args)
       {
          new practice();
       }
  } 
  </code></pre>
  
  <p>So, at first it obviously builds a window, 100 X 100 px big. It adds a button that says "press". When you press, it starts a new loop, every 30 milliseconds. 
  every iteration of the loop, it puts in a new <code>JOPtionPane.showMessageBox(null,...)</code> in a slightly different location.</p>
  
  <p>At first, when I just made it, I didn't know it would be unstoppable. I ran it, and had to restart my laptop. When I pressed ok, it would put in another box, in the exact same spot. When I tried to open task manager, it would automatically minimize it, and go back into the "virus" window. So, the laptop was unusable. I had to restart it, closing some of my dads tabs...</p>
  
  <p>Here are a few things I would like to find out;</p>
  
  <p>1) If I left this run over night, is it possible, that the laptop ran out or RAM, and if it did, what would happen?</p>
  
  <p>2) Can I make it that, when I press a button on the keyboard, the whole thing just closes?</p>
  
  <p>Like I said before, I was only trying to prank my friends, and the program happened to not be closable... any advice?</p>