MouseAdapter class in java
//MouseAdapter class
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code = "MouseAdapter_demo"
width = 200 height = 200></applet>
*/
public class MouseAdapter_demo extends JApplet
{
Container con;
public void init()
{
con = getContentPane();
con.setLayout(new FlowLayout());
addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent me)
{
con.setBackground(Color.red);
}
public void mouseExited(MouseEvent me)
{
con.setBackground(Color.blue);
}
});
}
}
OUTPUT:
when mouse Entered:
when mouse Leave:
Comments
Post a Comment