Hi, I need some help on this how can i use the arrow keys(up,down,left and right) in the keyboard so that the filloval will move, I have no idea on this.can you help me on this please.
Thank you in advance.
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TestPoint extends JFrame
{
int x = 10;
int y=100;
public TestPoint()
{
setTitle("sdfds");
setSize(400,400);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
addKeyListener(this);
}
public void paint(Graphics g)
{
super.paint(g);
this.setBackground(Color.white);
g.setColor(Color.RED);
g.fillOval(x,y,10,10);
}
public static void main(String[]c)
{
TestPoint t = new TestPoint();
t.setBackground(Color.white);
}
}