Print

Adapter Demo in Java

Vijay
Written by Vijay. Posted in Java & J2EE on 11 December 2009.
Hot 993 hits 0 favoured

import java.awt.*;

import java.awt.event.*;

import java.applet.*;

/*

*/

public class AdapterDemo extends Applet

{

        public void init()

        {

                addMouseListener(new MyMouseAdapter(this));

                addMouseMotionListener(new MyMouseMotionAdapter(this));

        }

}

class MyMouseAdapter extends MouseAdapter

{

        AdapterDemo adapterDemo;

        public MyMouseAdapter(AdapterDemo adapterDemo)

        {

                this.adapterDemo = adapterDemo;

        }

        public void mouseClicked(MouseEvent me)

        {

                adapterDemo.showStatus("Mouse Clicked");

        }

}

class MyMouseMotionAdapter extends MouseMotionAdapter

{

        AdapterDemo adapterDemo;

        public MyMouseMotionAdapter(AdapterDemo adapterDemo)

        {

                this.adapterDemo = adapterDemo;

        }

        public void mouseDragged(MouseEvent me)

        {

                adapterDemo.showStatus("Mouse dragged");

        }

}


Vijay

Author: Vijay

441 21813 3
I am Business Man...
  • No comments found
Powered by CjBlog