0% found this document useful (0 votes)
43 views6 pages

Mouse and Apllet

Uploaded by

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

Mouse and Apllet

Uploaded by

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

Mouse Event

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

/*<applet code="MouseCheck" height="400" width="400">


</applet>*/
public class MouseCheck extends Applet implements
MouseListener,MouseMotionListener
{
Label i;
int x,y;
int w,h;

public void init( )


{
x=100;
y=100;
w=100;
h=100;
addMouseListener(this);
addMouseMotionListener(this);
i=new Label("Mouse Not Entered in the applet");
i.setBounds(90,90,300,300);
add(i);
}

public void mouseClicked(MouseEvent e)


{
i.setText("Mouse Clicked");
}
public void mouseExited(MouseEvent e)
{
i.setText("Mouse Exited");
}

public void mouseEntered(MouseEvent e)


{
i.setText("Mouse Entered");
}

public void mouseReleased(MouseEvent e)


{
i.setText("Mouse Released");
}

public void mousePressed(MouseEvent e)


{
i.setText("Mouse Pressed");
}

public void mouseMoved(MouseEvent e)


{
showStatus("Mouse Moved");
x=e.getX( );
y=e.getY( );
w=10;
h=10;
repaint( );
}

public void mouseDragged(MouseEvent e)


{
showStatus("Mouse Dragged");
x=e.getX( );
y=e.getY( );
w=50;
h=50;
repaint( );
}

public void paint(Graphics g)


{
g.drawRect(x,y,w,h);
}
}
11.Using Applet and disply

import java.applet.*;
import java.awt.*;
/*
<APPLET code = "DispImg" height="500" width="500">
</APPLET>
*/

public class DispImg extends Applet


{
Image picture;

public void init( )


{
picture=getImage(getDocumentBase( ),"image.jpg");
}
public void paint(Graphics g)
{
int width=picture.getWidth(this);
int height=picture.getHeight(this);
g.drawImage(picture,200,20,width/7,height/7,this);
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy