ok i need help with this is statement at the buttom so here is the code (my first java game or going to be(maybe))


Please do not copy any of this code


package javaapplication1;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

/**
*
* @author jayden
*/
public class Chaser extends JFrame implements ActionListener{

/*
* This is just making JButtons and JPanels ignore look to buttom
*/
public JButton up, down, left, right,exit;
public JPanel playingField , grid3 = new JPanel();
public JPanel grid1 = new JPanel(), grid2 = new JPanel();
public double enemyX=400, enemyY=400, enemyXVel=0, enemyYVel=0, enemyR=10;
public double myX=40, myY=40, myXVel=0, myYVel=0, myR=10;

public Chaser(){
/*
* Constructor
*/
super();
this.setSize(500,500);
this.setExtendedState(MAXIMIZED_BOTH);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1,2));
grid1.setLayout(new GridLayout(3,1));
grid2.setLayout(new GridLayout(1,2));
grid3.setLayout(new GridLayout(1,2));

up = new JButton("UP");
up.addActionListener(this);
up.setBackground(Color.yellow);
grid1.add(up);
grid1.add(grid2);

down = new JButton("DOWN");
down.addActionListener(this);
down.setBackground(Color.yellow);
grid1.add(down);

left = new JButton("LEFT");
left.addActionListener(this);
left.setBackground(Color.yellow);
grid2.add(left);

right = new JButton("RIGHT");
right.addActionListener(this);
right.setBackground(Color.yellow);
grid2.add(right);

playingField = new JPanel();
playingField.setBackground(Color.WHITE);
grid3.setBackground(Color.WHITE);

this.add(grid1);
this.add(playingField);

while(true){
this.collisionCheck();
this.updatePos();
}

}
//main function
public static void main(String[] args) {new Chaser();}


//action performed: computer goes here everytime a buton is pressed.
@Override
public void actionPerformed(ActionEvent ae) {
if(ae.getSource().equals(up)){
myXVel -= .001;

}
if(ae.getSource().equals(left)){
myYVel -= .001;

}
if(ae.getSource().equals(right)){
myYVel += .001;

}
if(ae.getSource().equals(down)){
myXVel += .001;

}
}
// This is where i have my x + y stuff
private void updatePos() {
myX += myXVel;
myY += myYVel;
Graphics g = playingField.getGraphics();
g.setColor(Color.blue);
g.fillOval((int)myY ,(int) myX ,(int) myR ,(int) myR);
this.repaint();
Graphics g2 = playingField.getGraphics();
g.setColor(Color.red);
g.fillOval((int)enemyY ,(int) enemyX ,(int) enemyR ,(int) enemyR);
this.repaint();
if(myX < enemyX) {
enemyX -= .009;
} else {
enemyX += .009;
}
if(myY < enemyY) {
enemyY -= .009;
} else {
enemyY += .009;
}
}
private void collisionCheck() {
// my wall bounce stuff
if(myY > playingField.getHeight()){
myYVel = -myYVel;
}
if(myX > playingField.getWidth()){
myXVel = -myXVel;
}
if(myY < 0){
myYVel = -myYVel;
}
if(myX < 0){
myXVel = -myXVel;
}

// This is where i want the exit button to show up but it does not, it does not register the x and y it seems like
if(myY == enemyY) {
class exitApp implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
this.add(grid3);
exit = new JButton("EXIT");
exit.addActionListener(new exitApp());
exit.setBackground(Color.yellow);
playingField.add(grid3);
playingField.add(exit);
}

}
}