0% found this document useful (0 votes)
14 views

PR 11 Java

.

Uploaded by

Darshan Patil
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)
14 views

PR 11 Java

.

Uploaded by

Darshan Patil
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/ 5

package practical;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;

public class pra extends JFrame implements MouseListener

{
public pra()
{
this.addMouseListener(this);
}
public void mouseClicked(MouseEvent e)
{
int clicks=e.getClickCount();
switch(clicks)
{
case 1:
System.out.println("It is single click");
break;
case 2:
System.out.println("It is double click");
break;
case 3:
System.out.println("It is triple click");
break;
default:
System.out.println("It is multiple clicks");
break;
}
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e) { }
public static void main (String args[])
{
pra a=new pra();
a.setSize(500,500);
a.setVisible(true);
}
}
package practical;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class pr11 extends Frame implements MouseListener,


MouseMotionListener

{
public pr11()
{
addMouseListener(this);
addMouseMotionListener(this);
}
public void mousePressed(MouseEvent e)
{
setBackground(Color.red);
}
public void mouseReleased(MouseEvent e)
{
setBackground(Color.green);
}
public void mouseClicked(MouseEvent e)
{
setBackground(Color.green);
}
public void mouseEntered(MouseEvent e)
{
setBackground(Color.darkGray);
}
public void mouseExited(MouseEvent e)
{
setBackground(Color.orange);
}
public void mouseMoved(MouseEvent e)
{
setBackground(Color.cyan);
}
public void mouseDragged(MouseEvent e)
{
setBackground(Color.magenta);
}

public static void main(String args[])


{
pr11 a1= new pr11();
a1.setSize(300,300);
a1.setVisible(true);
}
}
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Ex16 extends Applet implements MouseMotionListener
{
public void init()
{
addMouseMotionListener(this);
}
public void mouseMoved(MouseEvent me)
{
showStatus("Mouse is moved to :"+me.getX()+","+me.getY());
}
public void mouseDragged(MouseEvent me)
{
showStatus("Mouse dragged to :"+me.getPoint());
}
}
/*
<applet code=Ex16 height=300 width=300>
</applet>
*/

You might also like