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

Write A Program To Demonstrate The Various Mouse Events Using MouseListener

Uploaded by

Nakshatra Pawar
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)
25 views

Write A Program To Demonstrate The Various Mouse Events Using MouseListener

Uploaded by

Nakshatra Pawar
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/ 6

Write a program to demonstrate the various Mouse Events using MouseListener.

import java.awt.*;

import java.awt.event.*;

public class Practical_11 extends Frame implements MouseListener

Label l;

Practical_11()

addMouseListener(this);

l=new Label();

l.setBounds(100,100,100,20);

add(l);

setTitle("Practical_11");

setSize(450,250);

setLayout(null);

setVisible(true);

public void mouseClicked(MouseEvent e)

l.setText("Mouse Clicked");

public void mouseEntered(MouseEvent e)

l.setText("Mouse Entered");

public void mouseExited(MouseEvent e)

l.setText("Mouse Exited");

public void mousePressed(MouseEvent e)


{

l.setText("Mouse Pressed");

public void mouseReleased(MouseEvent e)

l.setText("Mouse Released");

public static void main(String[] args)

Practical_11 p11 = new Practical_11();

O/P :
Write a program to demonstrate the use of JTextField and JPasswordField using Listener

Inetrface.

import javax.swing.*;

import java.awt.*;

public class Practical_12_JPasswordField

public static void main(String[] args)

JFrame f = new JFrame();

f.setTitle("Practical_12_JPasswordField");

f.setVisible(true); f.setSize(500,300);

f.setLayout(null);

JLabel jl = new JLabel("Enter Password : ");

jl.setBounds(80, 70, 100, 30);

JPasswordField pf = new JPasswordField(12);

pf.setBounds(80, 100, 250, 30);

pf.setEchoChar('$');

f.add(pf); f.add(jl);

O/P :
Write a program to demonstrate the use of Window Adapter Class.

import java.awt.*;

import java.awt.event.*;

public class Practical_13

{ Frame f;

Practical_13()

{ f = new Frame ("Window Adapter");

f.addWindowListener (new WindowAdapter()

{ public void windowClosing (WindowEvent e)

{ f.dispose();

});

f.setTitle("Practical_12");

f.setSize (400, 400);

f.setLayout (null);

f.setVisible (true);

public static void main(String[] args)

{ Practical_13 p13 = new Practical_13();

O/P :
Write a program to demonstrate the use of InetAddress class and its Factory Methods.

import java.io.*;

import java.net.*;

public class Practical_14

public static void main(String[] args)

try

InetAddress ip= InetAddress.getByName("localhost");

System.out.println("Host Name: "+ip.getHostName());

System.out.println("IP Address: "+ip.getHostAddress());

catch(Exception e)

System.out.println(e);

O/P :
Write a program to demonstrate the use of InetAddress class and its Factory Methods.

import java.io.*;

import java.net.*;

public class Practical_14

public static void main(String[] args)

try

InetAddress ip= InetAddress.getByName("localhost");

System.out.println("Host Name: "+ip.getHostName());

System.out.println("IP Address: "+ip.getHostAddress());

catch(Exception e)

System.out.println(e);

O/P :

You might also like