Action Event class in java Programming


An ActionEvent is generated when a button is pressed ,a lis item is double clicked or menu item is selected .The Action Event class defines four integer constants that can be used to identity any modifiers associated with an action event ALT_MASK ,CTRL_MASK,META_MASK and SHIFT_MASK.In addition there is an integer constant ACTION_PERFORMED which can be to identity action events

ActionEvent has these three constructors


ActionEvent(Object src,int type,String cmd)
ActionEvent(Object src,int type,String cmd,int modifiers)
ActionEvent(Object src,int type,String cmd,long when,int modifiers)


src is a reference to the object that generated this event .the type of the specified by Type ,and its command string is cmd,the argument modifiers indicates which modifiers key(ALT,CTRL,META,SHIFT) were pressed when the event was generated .The when parameter specifies when the event occurred.

getActionCommand()

When a button is pressed an action event is generated that has a command name equal to the label on that button

getModifiers()

The getModifiers() method returns a value that indicates which modifiers keys(ALT(CTRL,META,SHIFT) were pressed when the event was generated .

getWhen()

The getWhen() that returns the time at which the event took place.This is called the event's timestamps.


0 comments:

Post a Comment

 

learn java programming Copyright © 2011-2012 | Powered by appsackel.org