Java mouse event listening ActionListener and javaactionlistener
An Action event occurs when you click and open the mouse;
Method Abstract:
Actionreceivmed(ActionEvent e)
Called when an operation occurs.
Column:
Public class shijian extends Frame
{
Public static void main (String [] args)
{
Frame f = new Frame ();
F. setLayout (new FlowLayout (FlowLayout. LEFT, 20, 5 ));
Button b1 = new Button ("standalone ");
Button b2 = new Button ("double-click ");
// Button b3 = new Button ("a3 ");
// Create a listener
Myactionlistener m = new myactionlistener ();
B1.addActionListener (m); // register the m event listener with a b1 button.
F. add (b1 );
F. add (b2 );
// F. add (b3 );
F. pack ();
F. setVisible (true );
}
}
Class myactionlistener implements ActionListener // implements a listener class
{
@ Override
Public void actionreceivmed (ActionEvent e)
{
System. out. println ("standalone ");
// System. exit (0); // close the window with a button
}
}