import java.awt.*;
import java.applet.*;
/*
<html>
<body>
<h1>Java Applet Demo</h1>
<applet code=prg9.class width=500 height=350>
</applet>
</body>
</html>
*/
public class prg9 extends Applet
{
Label l1;
private int mouseX, mouseY;
private boolean mouseclicked = false;
public void init()
{
l1=new Label("Click Any Where On The Window.");
add(l1);
}
public void paint(Graphics g)
{
g.drawOval(40, 40, 120, 150);
g.drawOval(57, 75, 30, 30);
g.drawOval(110, 75, 30, 30);
g.fillOval(68, 81, 10, 10);
g.fillOval(121, 81, 10, 10);
g.drawLine(100, 100, 100, 117);
g.fillRect(60, 139, 80, 10);
if (mouseclicked)
{
g.clearRect(60, 139, 80, 10);
g.drawArc(70, 100, 60, 60, 0, -180);
mouseclicked = false;
}
}
public boolean mouseDown(Event e, int x, int y)
{
mouseX = x;
mouseY = y;
mouseclicked = true;
repaint();
return true;
}
}
import java.applet.*;
/*
<html>
<body>
<h1>Java Applet Demo</h1>
<applet code=prg9.class width=500 height=350>
</applet>
</body>
</html>
*/
public class prg9 extends Applet
{
Label l1;
private int mouseX, mouseY;
private boolean mouseclicked = false;
public void init()
{
l1=new Label("Click Any Where On The Window.");
add(l1);
}
public void paint(Graphics g)
{
g.drawOval(40, 40, 120, 150);
g.drawOval(57, 75, 30, 30);
g.drawOval(110, 75, 30, 30);
g.fillOval(68, 81, 10, 10);
g.fillOval(121, 81, 10, 10);
g.drawLine(100, 100, 100, 117);
g.fillRect(60, 139, 80, 10);
if (mouseclicked)
{
g.clearRect(60, 139, 80, 10);
g.drawArc(70, 100, 60, 60, 0, -180);
mouseclicked = false;
}
}
public boolean mouseDown(Event e, int x, int y)
{
mouseX = x;
mouseY = y;
mouseclicked = true;
repaint();
return true;
}
}
No comments:
Post a Comment