Escolar Documentos
Profissional Documentos
Cultura Documentos
code:
import java.awt.*;
import java.awt.event.*;
}
OUTPUT:
The frame is closed when user is closed or clicked on closed button of frame.
XIII.1.
CODE:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class prg
{
Label l1;
prg()
{
Frame f=new Frame();
f.setSize(300,300);
f.setVisible(true);
f.setLayout(new FlowLayout());
l1=new Label("Click Me");
f.add(l1);
f.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
l1.setText("Clicked event using Adapter Class");
}
}
);
}
OUTPUT:
XIII.2.
CODE:
interface Age
{
int x = 21;
void getAge();
}
class AnonymousDemo
{
public static void main(String[] args)
{
// Myclass is implementation class of Age interface
MyClass obj=new MyClass();
OUTPUT:
XIII.3.
CODE:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class prg
{
Label l1;
prg()
{
Frame f=new Frame();
f.setSize(300,300);
f.setVisible(true);
f.setLayout(new FlowLayout());
l1=new Label("Click Me");
f.add(l1);
f.addMouseMotionListener(new MouseMotionAdapter()
{
public void mouseDragged(MouseEvent e)
{
l1.setText(" dragged");
}
}
);