Advertisement
daniel199410

Broma

Feb 25th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. /*||Broma||
  2.  */
  3. package virus;
  4.  
  5. import java.awt.event.KeyEvent;
  6. import java.awt.event.KeyListener;
  7. import javax.swing.*;
  8. /**
  9.  *
  10.  * @author Daniel
  11.  */
  12. public class Virus extends JFrame implements KeyListener{
  13.    
  14.     private JLabel label1;
  15.     private JButton boton;
  16.    
  17.     public int setPlace(){
  18.         double x=Math.random()*500;
  19.         String valueOf;
  20.         valueOf = String.valueOf(Math.round(x));
  21.         return Integer.parseInt(valueOf);
  22.     }
  23.    
  24.     public Virus(){
  25.         super("*_* Virus");
  26.         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  27.         this.setLayout(null);
  28.         this.setSize(200,200);
  29.         this.setLocation(setPlace(),setPlace());
  30.         this.setResizable(false);
  31.         label1=new JLabel("       Virus");
  32.         label1.setBounds(55,80,55,10);
  33.         add(label1);
  34.         boton=new JButton(" ");
  35.         boton.setBounds(180,10,1,1);
  36.         boton.addKeyListener(this);
  37.         add(boton);
  38.         this.setVisible(true);
  39.     }
  40.    
  41.     public void Virus(){
  42.         int x=1;        
  43.         Virus v2=new Virus();
  44.         while(x<10){
  45.             v2=new Virus();
  46.             x++;
  47.         }
  48.     }
  49.    
  50.     public void keyReleased(KeyEvent e){
  51.        
  52.     }
  53.    
  54.     public void keyTyped(KeyEvent e){
  55.        
  56.     }
  57.    
  58.     public void keyPressed(KeyEvent e){
  59.         switch(e.getKeyCode()){
  60.             case KeyEvent.VK_F8:
  61.                 System.exit(0);
  62.         }
  63.     }
  64.    
  65.     public static void main(String[] args) {
  66.         Virus v1=new Virus();
  67.         v1.Virus();
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement