1.6 Develop an applet that uses the mouse listener, which overrides only two methods which are mousePressed and mouseReleased.
PressedReleased.java
import java.applet.*;import java.awt.*;import java.awt.event.*;/*<applet code="PressedReleased.class" height=400 width=800></applet>*/public class PressedReleased extends Applet implements MouseListener{String msg;public void init(){addMouseListener(this);}public void paint(Graphics g){g.drawString(msg,20,20);}public void mousePressed(MouseEvent me){msg="Mouse is Pressed";repaint();}public void mouseReleased(MouseEvent me){msg="Mouse is Released";repaint();}public void mouseClicked(MouseEvent me){}public void mouseEntered(MouseEvent me){}public void mouseExited(MouseEvent me){}}
0 Comments
Post a Comment