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

Practical 13ajp

Uploaded by

kirkhot56
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Practical 13ajp

Uploaded by

kirkhot56
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical 13

1.

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Practical_13{
Frame f;
public Practical_13 ()
{
f=new Frame("Window Adapter");
Label u=new Label("Welcome to window");
u.setBounds(30,40,150,30);
f.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent e) {
f.dispose(); } });
f.setSize(400, 400);
f.add(u);
f.setLayout(null);
f.setVisible(true); }
public static void main(String[] args) {
new Practical_13 ();
}
}
Output :-
2.

import java.awt.*;

import java.awt.event.*;

public class MouseAdapterExample extends

MouseAdapter {

Frame f;
MouseAdapterExample() {

f = new Frame("Mouse

Adapter");

f.addMouseListener(this);
f.setSize(300, 300);
f.setLayout(null);
f.setVisible(true);
f.addWindowListener(new WindowAdapter()

{ public void

windowClosing(WindowEvent we)

f.dispose();

});

public void mouseClicked(MouseEvent e) {

Graphics g = f.getGraphics();

g.setColor(Color.BLUE);
g.fillOval(e.getX(), e.getY(), 30, 30);

} public static void main(String[] args) {

new MouseAdapterExample();

}
Output :-

You might also like