rendered paste bodyimport java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;public class myJPanel extends JPanel implements MouseListener, MouseMotionListener, ActionListener, ChangeListener, KeyListener{ private Graphics g = null; //private Timer tim; //private int delay=1; private int startx=0, starty=0; private int LineThickness = 25; private Color myColor = Color.BLUE; private JButton btnLineThickness; private JTextField txtLineThickness; private Graphics drawing; JButton b; public myJPanel() { super(); //create the timer. //tim = new Timer(delay, this); //tim.addActionListener(this); //tim.start(); addMouseListener(this); setLayout(new BorderLayout()); addMouseMotionListener(this); //line thickness box txtLineThickness = new JTextField("Frames: 0", 10); btnLineThickness = new JButton("Change Line Thickness"); btnLineThickness.addActionListener(this); b = new JButton(""); b.addKeyListener(this); b.requestFocusInWindow(); //create the new panel, and add the buttons JPanel colorPanel = new JPanel(); colorPanel.add(txtLineThickness); //keys colorPanel.add(b); //add to the panel add(colorPanel, BorderLayout.SOUTH); drawing = getGraphics(); } /***************** * Paint *****************/ public void paintComponent(Graphics g) { g = getGraphics(); g.setColor(myColor); g.fillOval(startx,starty,LineThickness, LineThickness); repaint(); } /*********************** * Regular Actions ***********************/ public void actionPerformed(ActionEvent event) { Object obj = event.getSource(); //if(obj == tim) //{ //repaint(); //} } /***************** * Mouse Events *****************/ public void mouseDragged(MouseEvent pt) { startx = pt.getX(); starty = pt.getY(); } public void mouseClicked(MouseEvent e){} public void mouseMoved(MouseEvent pt){} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void stateChanged(ChangeEvent event) {} public void keyPressed(KeyEvent e) { int x = e.getKeyCode(); //left arrow if(x == e.VK_LEFT) { startx = startx - 25; } //Right arrow if(x == e.VK_RIGHT) { startx= startx + 25; } //Space if(x == e.VK_SPACE) { //code for space goes here. } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { }}