20Java19javajava.awt.eventJavaadapterinnerinner20.1Java1.01.11.01.0Java220.2delegationeventmodel:sourceeventlistenersJava1.04482JavaJavaawt2220.2.120.2.2,publicvoidaddTypeListener(TypeListenerel)typeeladdKeyListener()addMouseMotionListener()multicasting:publicvoidaddTypeListener(TypeListenerel)throwsjava.util.TooManyListenersExceptiontypeelpublicvoidremoveTypeListener(TypeListenerel)typeelremoveKeyListener()component2044920.2.3java.awt.eventMouseMotionListener20.3Javajava.utilEventObjectJava:EventObject(Objectsrc)srcEventObjectgetSource()toString()GetSource():ObjectgetSource()java.awtAWTEventEventObjectawtgetID()intgetID()AWTEvent22AWTEventEventObjectAWTEventAWTjava.awt.event20-14502Java20-1java.awt.eventActionEventAdjustmentEventComponentEventContainerEventFocusEventInputEventItemEventKeyEventMouseEventTextEventWindowEvent20.3.1ActionEventActionEventActionEventALT_MASKCTRL_MASKMETA_MASKSHIFT_MASKACTION_PERFORMEDActionEventActionEvent(Objectsrc,inttype,Stringcmd)ActionEvent(Objectsrc,inttype,Stringcmd,intmodifiers)srctypecmdmodifiersALT,CTRL,META,SHIFTActionEventgetActionCommand()StringgetActionCommand()ActionEventintgetModifiers()ALT,CTRL,META,SHIFT2045120.3.2AdjustmentEventAdjustmentEventAdjustmentEventBLOCK_DECREMENTBLOCK_INCREMENTTRACKUNIT_DECREMENTUNIT_INCREMENTADJUSTMENT_VALUE_CHANGEDAdjustmentEventAdjustmentEvent(Adjustablesrc,intid,inttype,intdata)srcidADJUSTMENT_VALUE_CHANGEDtypedatagetAdjustable()AdjustablegetAdjustable()getAdjustmentType()AdjustmentEventintgetAdjustmentType()getValue()intgetValue()20.3.3ComponentEventComponentEventComponentEventCOMPONENT_HIDDENCOMPONENT_MOVEDCOMPONENT_RESIZEDCOMPONENT_SHOWNComponentEventComponentEvent(Componentsrc,inttype)4522JavasrcTypeComponentEventContainerEvent,FocusEvent,KeyEvent,MouseEventWindowEventgetComponent()ComponentgetComponent()20.3.4ContainerEventContainerEventContainerEventCOMPONENT_ADDEDCOMPONENT_REMOVEDContainerEventComponentEventContainerEvent(Componentsrc,inttype,Componentcomp)srcTypeCompgetContainer()ContainergetContainer()getChild()ComponentgetChild()20.3.5FocusEventFocusEventFOCUS_GAINEDFOCUS_LOSTFocusEventComponentEventFocusEvent(Componentsrc,inttype)FocusEvent(Componentsrc,inttype,booleantemporaryFlag)srcTypetemporaryFlagtruefalseisTemporary()booleanisTemporary()truefalse2045320.3.6InputEventInputEventComponentEventKeyEventMouseEventInputEventALT_MASKBUTTON2_MASKMETA_MASKALT_GRAPH_MASKBUTTON3_MASKSHIFT_MASKBUTTON1_MASKCTRL_MASKisAltDown()isAltGraphDown()isControlDown()isMetaDown()isShiftDown()booleanisAltDown()booleanisAltGraphDown()booleanisControlDown()booleanisMetaDown()booleanisShiftDown()intgetModifiers()20.3.7ItemEventItemEventDESELECTEDSELECTEDItemEventITEM_STATE_CHANGEDItemEventItemEvent(ItemSelectablesrc,inttype,Objectentry,intstate)srcTypeentrystateGetItemObjectgetItem()getItemSelectable()ItemSelectableItemSelectablegetItemSelectable()4542JavaItemSelectablegetStateChange()intgetStateChange()20.3.8KeyEventKeyEventKEY_PRESSEDKEY_RELEASEDKEY_TYPEDSHIFTKeyEventVK_0VK_9VK_AVK_ZASCIIVK_ENTERVK_ESCAPEVK_CANCELVK_UPVK_DOWNVK_LEFTVK_RIGHTVK_PAGE_DOWNVK_PAGE_UPVK_SHIFTVK_ALTVK_CONTROLVKvirtualkeycodescontrolshiftaltKeyEventInputEventKeyEvent(Componentsrc,inttype,longwhen,intmodifiers,intcode)KeyEvent(Componentsrc,inttype,longwhen,intmodifiers,intcode,charch)srcTypewhenModifiersVK_UPVK_AcodechchCHAR_UNDEFINEDKEY_TYPEDcodeVK_UNDEFINEDKeyEventgetKeyCode()chargetKeyChar()intgetKeyCode()getKeyChar()CHAR_UNDEFINEDKEY_TYPEDgetKeyCode()VK_UNDEFINED20.3.9MouseEvent7MouseEventMOUSE_CLICKEDMOUSE_DRAGGED20455MOUSE_ENTEREDMOUSE_EXITEDMOUSE_MOVEDMOUSE_PRESSEDMOUSE_RELEASEDMouseEventInputEventMouseEvent(Componentsrc,inttype,longwhen,intmodifiers,intx,inty,intclicks,booleantriggersPopup)srcTypewhenmodifiersxyclickstriggersPopupgetX()getY()XYintgetX()intgetY()getPoint()PointgetPoint()PointxytranslatePoint()voidtranslatePoint(intx,inty)xygetClickCount()intgetClickCount()isPopupTrigger()booleanisPopupTrigger()20.3.10TheTextEventClassTextEventTEXT_VALUE_CHANGEDTextEvent(Objectsrc,inttype)srcType4562JavaTextEventTextEvent20.3.11WindowEventWindowEventWINDOW_ACTIVATEDWINDOW_CLOSEDWINDOW_CLOSINGWINDOW_DEACTIVATEDWINDOW_DEICONIFIEDWINDOW_ICONIFIEDWINDOW_OPENEDWindowEventComponentEventWindowEvent(Windowsrc,inttype)srcTypegetWindow()WindowWindowgetWindow()20.420-220-220-2ButtonCheckboxChoiceList20457MenuitemScrollbarTextcomponentsWindow20.5java.awt.event20-320-3ActionListenerAdjustmentListenerComponentListenerContainerListenerFocusListenerItemListenerKeyListenerMouseListenerMouseMotionListenerTextListenerWindowListener20.5.1ActionListeneractionPerformed()voidactionPerformed(ActionEventae)4582Java20.5.2AdjustmentListeneradjustmentValueChanged()voidadjustmentValueChanged(AdjustmentEventae)20.5.3ComponentListenervoidcomponentResized(ComponentEventce)voidcomponentMoved(ComponentEventce)voidcomponentShown(ComponentEventce)voidcomponentHidden(ComponentEventce)AWTcomponentResized()componentMoved()20.5.4ContainerListenercomponentAdded()componentRemoved()voidcomponentAdded(