Panelball class: import java.awt.*;import java.awt.event.KeyEvent;import javax.swing.*;public class Panelball extends JPanel implements Runnable {    private static final long serialVersionUID = 1L;    private int ballX = 10, ballY = 100, ply1X=10, ply1Y=100, ply2X=230, ply2Y=100;    Thread string;    int right=5;    int left= -5;    int up=5;    int down= -5;    int width, height;    int contPlay1=0, contPlay2=0;    boolean player1FlagArr,player1FlagAba, player2FlagArr, player2FlagAba;    boolean playin, gameOver;    public Panelball(){            playin=true;            string=new Thread(this);            string.start();    }    public void paintComponent(Graphics gc){            setOpaque(false);            super.paintComponent(gc);            gc.setColor(Color.black);            gc.fillOval(ballX, ballY, 8,8);            gc.fillRect(ply1X, ply1Y, 10, 25);            gc.fillRect(ply2X, ply2Y, 10, 25);            gc.drawString(Score1: +contPlay1, 25, 10);            gc.drawString(Score2: +contPlay2, 150, 10);            if(gameOver)                    gc.drawString(Game Over, 100, 125);    }    public void drawball (int nx, int ny)    {            ballX= nx;             ballY= ny;             this.width=this.getWidth();            this.height=this.getHeight();            repaint();    }    public void keyPressed(KeyEvent evt)    {            switch(evt.getKeyCode())            {                    case KeyEvent.VK_W :                            player1FlagArr = true;                            break;                    case KeyEvent.VK_S :                             player1FlagAba = true;                            break;                    case KeyEvent.VK_UP:                            player2FlagArr=true;                            break;               case KeyEvent.VK_DOWN:                       player2FlagAba=true;                            break;            }    }    public void keyReleased(KeyEvent evt)    {            switch(evt.getKeyCode())            {                    case KeyEvent.VK_W :                            player1FlagArr = false;                            break;                    case KeyEvent.VK_S :                             player1FlagAba = false;                            break;                    case KeyEvent.VK_UP:                            player2FlagArr=false;                            break;                    case KeyEvent.VK_DOWN:                       player2FlagAba=false;                            break;            }    }    public void moverPlayer1()    {            if (player1FlagArr == true && ply1Y >= 0)                    ply1Y += down;            if (player1FlagAba == true && ply1Y <= (this.getHeight()-25))                    ply1Y += up;            drawPlayer1(ply1X, ply1Y);    }    public void moverPlayer2()    {            if (player2FlagArr == true && ply2Y >= 0)                    ply2Y += down;            if (player2FlagAba == true && ply2Y <= (this.getHeight()-25))                    ply2Y += up;            drawPlayer2(ply2X, ply2Y);    }    public void drawPlayer1(int x, int y){            this.ply1X=x;            this.ply1Y=y;            repaint();    }    public void drawPlayer2(int x, int y){            this.ply2X=x;            this.ply2Y=y;            repaint();    }    public void run() {            boolean lftrgt=false;            boolean updwn=false;            while(true){                    if(playin){                    if (lftrgt)                     {                            ballX += right;                            if (ballX >= (width - 8))                                    lftrgt= false;                    }                    else                    {                            ballX += left;                            if ( ballX <= 0)                                    lftrgt =  true;                    }                    if (updwn)                     {                            ballY += up;                            if (ballY >= (height - 8))                                    updwn= false;                    }                    else                    {                            ballY += down;                            if ( ballY <= 0)                                    updwn =  true;                    }                    drawball(ballX, ballY);                    try                     {                            Thread.sleep(50);                    }                    catch(InterruptedException ex)                    {                    }                    moverPlayer1();                    moverPlayer2();                    if (ballX >= (width - 8))                            contPlay1++;                    if ( ballX == 0)                            contPlay2++;                    if(contPlay1==6 || contPlay2==6){                            playin=false;                            gameOver=true;                    }                    if(ballX==ply1X+10 && ballY>=ply1Y && ballY<=(ply1Y+25))                            lftrgt=true;                    if(ballX==(ply2X-5) && ballY>=ply2Y && ballY<=(ply2Y+25))                            lftrgt=false;                    }            }    }}Main Class:import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Main extends JFrame {    private static final long serialVersionUID = 1L;    private JPanel jContentPane = null;    private Panelball panel = null;    private Panelball getPanel() {            if (panel == null) {                    panel = new Panelball();             }            return panel;    }    public Main() {            super();            initialize();            this.addKeyListener(new KeyAdapter() {                    public void keyPressed(KeyEvent evt) {                            formKeyPressed(evt);                    }                    public void keyReleased(KeyEvent evt) {                            formKeyReleased(evt);                    }            });    }    private void formKeyPressed(KeyEvent evt)    {            panel.keyPressed(evt);    }    private void formKeyReleased(KeyEvent evt)    {            panel.keyReleased(evt);    }    private void initialize() {            this.setResizable(false);            this.setBounds(new Rectangle(312, 184, 250, 250));            this.setMinimumSize(new Dimension(250, 250));            this.setMaximumSize(new Dimension(250, 250));            this.setContentPane(getJContentPane());            this.setTitle(Pong);    }    private JPanel getJContentPane() {            if (jContentPane == null) {                    jContentPane = new JPanel();                    jContentPane.setLayout(new BorderLayout());                    jContentPane.add(getPanel(), BorderLayout.CENTER);            }            return jContentPane;    }    public static void main(String[] args) {            SwingUtilities.invokeLater(new Runnable() {                    public void run() {                            Main thisClass = new Main();                            thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);                            thisClass.setVisible(true);                    }            });    }}//It would be a huge help if you could tell me ways to make my code run smoother and if I could add more code to my program to make my program more unique. =D thanks so much for your time
High School Java Class: Pong Project External Reviewer
java;strings;game;array
Uniqueness should not be your goal (except you copied it completely from somebody else ;) ) In general you should aim for removing stuff and still let it work as expected and not adding unnecessary stuff. Do you have test, that is something you should add always?Some hints:make your fields private instead of defaultdon't use abbreviation, or use them in a consistent way (ply1.. vs. player1..., Aba?) why is your Thread called string? playin?Did you notice that you duplicate some code for Player 1 and 2? Maybe it's a good idea to create a player class? If you have player objects a ball object would also be nice. You could encapsulate the drawing and movement. Beside better readability, it would also be easier to write a test for the object movements.If you want to restart your game later you could also put the remaining variables in a game class. So you could move your whole logic out of the panel, which main purpose should be only displaying stuff and not more.