MarinaNimmons 0 Newbie Poster

"Write an applet that draws the house (house Rectangle white, two quader windows black, triangle ruff white, rectangle door black. When the user user clicks on the door or windows, they should close, The figure should look clear ruff, clear house rectangle, clear door with door opener (circle black), windows clear, but lines goes through them like they have been devided in 4 quaders.

here is what i have.... Please HELP ME!!!

import java.awt.event.MouseEvent;
import javax.swing.*;
import java.awt.*;
import java awt.event.MouseListener;

//this class demonstrates drawn rectangle

public class MouseEvents extends JApplet

{
private Graphics[] mouseStates;

public void init()

//create a layout manager
setLayout(new FlowLayout());


//Create the array of Graphics
mouseStates = new Graphics[5];
for (int i = 0; i < mouseStates.length; i++)

public void paint(Graphics g)
{

super.paint(g);
setBackgroundColor(Color.WHITE);
 
g.setColor(Color.WHITE); 
g.fillRect(100,100,300,100);
g.drawLine(100,100,250,25); 
g.drawLine(250,25,400,100);

g.setColor(Color.BLACK); 
g.fillRect(125,125,20,20); 
g.fillRect(355,125,20,20);
 
g.setColor(Color.BLACK); 
g.fillRect(240,150, 30,50);
} 
}
//add a mouse listener to this applet
addMouseListener(new MyMouseListener());

//add a mouse motion listener to this applet
addMouseMotionListener(new MyMouseMotionListener());

// changes the window and door
public void clearGraphics()
{
for (int i = 0; i < 3; i++)
mouseStates[i].setBackground(Color.WHITE);
}

private class MyMouseListener implements MouseListener
{
public void mouseClicked(MouseEvent e)
{
clearGraphics();
mouseStates[1].setBackground(Color.WHITE)
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.