Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*||Broma||
- */
- package virus;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import javax.swing.*;
- /**
- *
- * @author Daniel
- */
- public class Virus extends JFrame implements KeyListener{
- private JLabel label1;
- private JButton boton;
- public int setPlace(){
- double x=Math.random()*500;
- String valueOf;
- valueOf = String.valueOf(Math.round(x));
- return Integer.parseInt(valueOf);
- }
- public Virus(){
- super("*_* Virus");
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setLayout(null);
- this.setSize(200,200);
- this.setLocation(setPlace(),setPlace());
- this.setResizable(false);
- label1=new JLabel(" Virus");
- label1.setBounds(55,80,55,10);
- add(label1);
- boton=new JButton(" ");
- boton.setBounds(180,10,1,1);
- boton.addKeyListener(this);
- add(boton);
- this.setVisible(true);
- }
- public void Virus(){
- int x=1;
- Virus v2=new Virus();
- while(x<10){
- v2=new Virus();
- x++;
- }
- }
- public void keyReleased(KeyEvent e){
- }
- public void keyTyped(KeyEvent e){
- }
- public void keyPressed(KeyEvent e){
- switch(e.getKeyCode()){
- case KeyEvent.VK_F8:
- System.exit(0);
- }
- }
- public static void main(String[] args) {
- Virus v1=new Virus();
- v1.Virus();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement