I need to finish writing an applet that displays a rectangle on a black backgrou
ID: 3652924 • Letter: I
Question
I need to finish writing an applet that displays a rectangle on a black background. The rectangle can be filled with one of 5 colors, available through radiobuttons located at the top of the applet. The rectangle also must be able to be moved with the arrow keys and have its perimeter adjusted by the user through clicking and dragging. Below are links to incomplete files: https://docs.google.com/document/d/1dBnp6GMleoABuJ_WEpYwpEimEynHH5I5Jo-8IRcagWI/edit (Describes the assignment) https://docs.google.com/open?id=0B3FjdLAPDWXRcks1TjlBdjJfeUk (Drives the program...doesn't need any editing as far as I know) https://docs.google.com/open?id=0B3FjdLAPDWXRTnZkaDF2djBhdGM (Class file for the applet, is incomplete) https://docs.google.com/open?id=0B3FjdLAPDWXRdExQNmxwcU9oREE (RadioButton file...getting a lot of errors. You can correct it or just make a new one) https://docs.google.com/open?id=0B3FjdLAPDWXRbEpYakItMVFCTVk (HTML file for running the applet) I greatly appreciate any help you can provide. There's not much that needs to be done, just several small parts, but our lecturer does a poor job at explaining and I have no idea how to continue.Explanation / Answer
for clicking: import java.awt.*; import java.awt.event.*; import java.applet.*; public class mouse extends Applet implements MouseListener,MouseMotionListener { int p,q; public void init(){addMouseListener(this);addMouseMotionListener(this);} public void mouseClicked(MouseEvent k){} public void mouseEntered(MouseEvent k){repaint();} public void mouseExited(MouseEvent m){} public void mousePressed(MouseEvent n){p=m.getX();q=m.getY();} public void mouseReleased(MouseEvent k){} public void mouseDragged(MouseEvent p){} public void mouseMoved(MouseEvent e){} public void paint(Graphics f){f.drawRect(p,q);} } for dragging: import java.awt.*; import java.awt.event.*; import java.applet.*; public class mouse extends Applet implements MouseListener,MouseMotionListener { int p,q; public void init(){addMouseListener(this);addMouseMotionListener(this);} public void mouseClicked(MouseEvent k){} public void mouseEntered(MouseEvent k){repaint();} public void mouseExited(MouseEvent m){} public void mousePressed(MouseEvent n){} public void mouseReleased(MouseEvent k){} public void mouseDragged(MouseEvent p){p=m.getX();q=m.getY();} public void mouseMoved(MouseEvent e){}) public void paint(Graphics f){f.drawRect(p,q);} }