need some java help

Discussion in 'OT Technology' started by High Voltage, Mar 30, 2006.

  1. High Voltage

    High Voltage Guest

    the purpose of this program is to draw a rectangle, then when the mouse is double clicked it disappears then when the mouse is clicked onces it reappears but it doesnt compile. please help i am a newbie at this stuff

    edit: solved it thanks though!

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;

    public class rectangle extends Applet implements MouseListener {


    public void init() {
    setBackground(Color.black);
    addMouseListener(this);
    }

    public void mousePressed(MouseEvent evt) {

    if ( evt.getClickCount()==2 ) {
    repaint();
    return;
    }
    Graphics g = getGraphics();
    {

    g.setColor(Color.red);
    g.fillRect( 25, 25, 100, 100 );
    g.setColor(Color.black);
    g.drawRect( 25, 25, 100, 100 );
    }

    g.dispose();

    }

    public void mouseEntered(MouseEvent evt) { }
    public void mouseExited(MouseEvent evt) { }
    public void mouseClicked(MouseEvent evt) { }
    public void mouseReleased(MouseEvent evt) { }


    }
     
    Last edited by a moderator: Mar 30, 2006

Share This Page