I am trying to write a program that displays a rectangle when user drag the mouse and when user release mouse, it displays the rectangle with green color.
I am terribly confused here is what I am thinking to do
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class DragRectangle extends JApplet
{
public void paint(Graphics g)
{
super.paint(g)
}
public void mouseDragged(MouseEvent e)
{
e.setColor(Color.GREEN)
e.drawRect(I am not sure what the coordinate will be)
repaint();
}
Am I in right track? Any suggestion or help will be highly appreciated!!