0% found this document useful (0 votes)
29 views3 pages

AJP Practical11

Java practical 11

Uploaded by

oj227754
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

AJP Practical11

Java practical 11

Uploaded by

oj227754
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical No 11:

***Write a program to change the background color of Applet when user performs event using
Mouse.

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

public class MouseColor extends Applet implements MouseMotionListener


{
public void init()
{
addMouseMotionListener(this);
}

public void mouseDragged(MouseEvent me)


{
setBackground(Color.red);
repaint();
}

public void mouseMoved(MouseEvent me)


{
setBackground(Color.green);
repaint();
}

}
/*
<applet code="MouseColor" width=300 height=300>
</applet>

*/Output:-
** Write a program to count the number of clicks performed by the user in a applet?

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

public class MouseCount extends Applet implements MouseListener


{
int count = 0;
public void init()
{
addMouseListener(this);
}

public void mouseClicked(MouseEvent me)


{
count++;
showStatus("Number of time Clicked:"+count);
repaint();
}

public void mouseEntered(MouseEvent me)


{
}
public void mouseExited(MouseEvent me)
{
}
public void mousePressed(MouseEvent me)
{
}
public void mouseReleased(MouseEvent me)
{
}
}
/*
<applet code="MouseCount" width=300 height=300>
</applet>
*/

Output:-

You might also like