1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pongnew;

import java.awt.Color;
import java.awt.Graphics;
import java.util.logging.*;
import javax.swing.*;

/**
 *
 * @author User
 */
public class Main extends JFrame implements Runnable{
    JPanel p = new JPanel();;
    Racket p1,comp;
    public Main(){
        //Form info
        super("Pong - made by Alex.");
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(400,300);
        setResizable(false);
        //JPanel
        p.setBackground(new Color(0,155,0));
        this.add(p);
    }
    public static void main(String[] args) {
        new Main();
    }

    public void paint(Graphics g){
        super.paint(g);
        //Players
        p1 = new Racket(20, this.getHeight()/3, 20, 100, this.getHeight(), false, g, p.getBackground());
        comp = new Racket(this.getWidth()-40, this.getHeight()/3, 20, 100, this.getHeight(), true, g, p.getBackground());
        //KeyListeners
        this.addKeyListener(p1);
        this.addKeyListener(comp);
        //draw Players
        p1.drawMe();
        comp.drawMe();
    }

    public void run() {

    }

}