°Ë±¦Êé¿â > ÎÄѧÆäËûµç×ÓÊé > Java±à³Ì˼ÏëµÚ4°æ[ÖÐÎÄ°æ](PDF¸ñʽ) >

µÚ109²¿·Ö

Java±à³Ì˼ÏëµÚ4°æ[ÖÐÎÄ°æ](PDF¸ñʽ)-µÚ109²¿·Ö

С˵£º Java±à³Ì˼ÏëµÚ4°æ[ÖÐÎÄ°æ](PDF¸ñʽ) ×ÖÊý£º ÿҳ4000×Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡




¡¡¡¡¡¡¡¡¡¡¡¡getAppletContext£¨£©¡£showStatus£¨¡¨Button¡¡1¡¨£©£»¡¡¡¡

¡¡¡¡¡¡¡¡£ý¡¡¡¡

¡¡¡¡£ý¡¡¡¡

¡¡¡¡class¡¡B2¡¡implements¡¡ActionListener¡¡£û¡¡¡¡

¡¡¡¡¡¡¡¡public¡¡void¡¡actionPerformed£¨ActionEvent¡¡e£©¡¡£û¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡getAppletContext£¨£©¡£showStatus£¨¡¨Button¡¡2¡¨£©£»¡¡¡¡

¡¡¡¡¡¡¡¡£ý¡¡¡¡

¡¡¡¡£ý¡¡¡¡

¡¡¡¡/*¡¡The¡¡old¡¡way£º¡¡¡¡

¡¡¡¡public¡¡boolean¡¡action£¨Event¡¡evt£»¡¡Object¡¡arg£©¡¡£û¡¡¡¡

¡¡¡¡¡¡¡¡if£¨evt¡£target¡£equals£¨b1£©£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡getAppletContext£¨£©¡£showStatus£¨¡¨Button¡¡1¡¨£©£»¡¡¡¡

¡¡¡¡¡¡¡¡else¡¡if£¨evt¡£target¡£equals£¨b2£©£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡getAppletContext£¨£©¡£showStatus£¨¡¨Button¡¡2¡¨£©£»¡¡¡¡

¡¡¡¡¡¡¡¡//¡¡Let¡¡the¡¡base¡¡class¡¡handle¡¡it£º¡¡¡¡

¡¡¡¡¡¡¡¡else¡¡¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡409¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡411¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡return¡¡super¡£action£¨evt£»¡¡arg£©£»¡¡¡¡

¡¡¡¡¡¡¡¡return¡¡true£»¡¡//¡¡We've¡¡handled¡¡it¡¡here¡¡¡¡

¡¡¡¡£ý¡¡¡¡

¡¡¡¡*/¡¡¡¡

£ý¡¡///£º~¡¡¡¡

¡¡¡¡

ÎÒÃǿɱȽÏÁ½ÖÖ·½·¨£¬ÀϵĴúÂëÔÚ×óÃæ×÷Ϊע½â¡£ÔÚ¡¡init£¨£©·½·¨ÀֻÓÐÒ»¸ö¸Ä±ä¾ÍÊÇÔö¼ÓÁËÏÂÃæµÄÁ½ÐУº¡¡¡¡

b1¡£addActionListener£¨new¡¡B1£¨£©£©£»¡¡¡¡

b2¡£addActionListener£¨new¡¡B2£¨£©£©£»¡¡¡¡

°´Å¥°´ÏÂʱ£¬addActionListener£¨£©Í¨Öª°´Å¥¶ÔÏó±»¼¤»î¡£B1¡¡ºÍB2¡¡À඼ÊÇÖ´ÐнӿÚActionListener¡¡µÄÄÚ²¿¡¡

Àà¡£Õâ¸ö½Ó¿Ú°üÀ¨Ò»¸öµ¥Ò»µÄ·½·¨¡¡actionPerformed£¨£©¡¡£¨ÕâÒâζ×ŵ±Ê¼þ¼¤»îʱ£¬Õâ¸ö¶¯×÷½«±»Ö´ÐУ©¡£×¢¡¡

ÒâactionPreformed£¨£©·½·¨²»ÊÇÒ»¸öÆÕͨʼþ£¬ËµµÃ¸üÇ¡µ±Ð©ÊÇÒ»¸öÌØÊâÀàÐ͵Äʼþ£¬ActionEvent¡£Èç¹ûÎÒ¡¡

ÃÇÏëÌáÈ¡ÌØÊâActionEvent¡¡µÄÐÅÏ¢£¬Òò´ËÎÒÃDz»ÐèÒª¹ÊÒâÈ¥²âÊÔºÍÏÂËÝÔìÐÍ×Ô±äÁ¿¡£¡¡¡¡

¶Ô±à³ÌÕßÀ´ËµÒ»¸ö×îºÃµÄʱãÊÇactionPerformed£¨£©Ê®·ÖµÄ¼òµ¥Ò×Óá£ËüÊÇÒ»¸ö¿ÉÒÔµ÷Óõķ½·¨¡£Í¬Àϵġ¡

action£¨£©·½·¨±È½Ï£¬Àϵķ½·¨ÎÒÃDZØÐëÖ¸³ö·¢ÉúÁËʲôºÍÊʵ±µÄ¶¯×÷£¬Í¬Ñù£¬ÎÒÃǻᵣÐĵ÷Óûù´¡Àà¡¡

action£¨£©µÄ°æ±¾²¢ÇÒ·µ»ØÒ»¸öֵȥָÃ÷ÊÇ·ñ±»´¦Àí¡£ÔÚеÄʼþÄ£ÐÍÖУ¬ÎÒÃÇÖªµÀËùÓÐʼþ²âÊÔÍÆÀí×Ô¶¯½ø¡¡

ÐУ¬Òò´ËÎÒÃDz»±ØÖ¸³ö·¢ÉúÁËʲô£»ÎÒÃǸոձíʾ·¢ÉúÁËʲô£¬Ëü¾Í×Ô¶¯µØÍê³ÉÁË¡£Èç¹ûÎÒÃÇ»¹Ã»ÓÐÌá³öÓá¡

еķ½·¨¸²¸ÇÀϵķ½·¨£¬ÎÒÃÇ»áºÜ¿ìÌá³ö¡£¡¡¡¡



13¡£16¡£2¡¡Ê¼þºÍ½ÓÊÕÕßÀàÐÍ¡¡¡¡



ËùÓÐAWT¡¡×é¼þ¶¼±»¸Ä±ä³É°üº¬addXXXListener£¨£©ºÍremoveXXXListener£¨£©·½·¨£¬Òò´ËÌض¨µÄ½ÓÊÕÆ÷ÀàÐÍ¿É´Ó¡¡

ÿ¸ö×é¼þÖÐÔö¼ÓºÍɾ³ý¡£ÎÒÃÇ»á×¢Òâµ½¡°XXX¡±ÔÚÿ¸ö³¡ºÏÖÐͬÑù±íʾ×Ô±äÁ¿µÄ·½·¨£¬ÀýÈ磬¡¡

addFooListener£¨FooListener¡¡fl£©¡£ÏÂÃæÕâÕűí¸ñ×ܽáÁËͨ¹ýÌṩaddXXXListener£¨£©ºÍ¡¡removeXXXListener£¨£©¡¡

·½·¨£¬´Ó¶øÖ§³ÖÄÇЩÌض¨Ê¼þµÄÏà¹Øʼþ¡¢½ÓÊÕÆ÷¡¢·½·¨ÒÔ¼°×é¼þ¡£¡¡¡¡

ʼþ£¬½ÓÊÕÆ÷½Ó¿Ú¼°Ìí¼ÓºÍɾ³ý·½·¨¡¡Ö§³ÖÕâ¸öʼþµÄ×é¼þ¡¡¡¡

¡¡¡¡



Event£»¡¡listener¡¡interface¡¡and¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡s¡¡¡¡s¡¡u¡¡p¡¡p¡¡o¡¡r¡¡t¡¡i¡¡n¡¡g¡¡¡¡t¡¡h¡¡i¡¡s¡¡¡¡e¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡

add¡¡¡¡¡¡a¡¡n¡¡d¡¡¡¡¡¡r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡m¡¡e¡¡t¡¡h¡¡o¡¡d¡¡s¡¡¡¡¡¡



A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡B¡¡u¡¡t¡¡t¡¡o¡¡n¡¡£»¡¡L¡¡i¡¡s¡¡t¡¡£»¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡£»¡¡¡¡M¡¡e¡¡n¡¡u¡¡I¡¡t¡¡e¡¡m¡¡£»¡¡¡¡and¡¡its¡¡derivatives¡¡¡¡

A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡including¡¡C¡¡h¡¡e¡¡c¡¡k¡¡b¡¡o¡¡x¡¡M¡¡e¡¡n¡¡u¡¡I¡¡t¡¡e¡¡m¡¡£»¡¡M¡¡e¡¡n¡¡u¡¡£»¡¡¡¡and¡¡P¡¡o¡¡p¡¡u¡¡p¡¡M¡¡e¡¡n¡¡u¡¡¡¡¡¡

a¡¡d¡¡d¡¡A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡¡¡£©¡¡¡¡¡¡



A¡¡d¡¡j¡¡u¡¡s¡¡t¡¡m¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡S¡¡c¡¡r¡¡o¡¡l¡¡l¡¡b¡¡a¡¡r¡¡¡¡

A¡¡d¡¡j¡¡u¡¡s¡¡t¡¡m¡¡e¡¡n¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡Anything¡¡you¡¡create¡¡that¡¡implements¡¡the¡¡Adjustable¡¡interface¡¡¡¡

a¡¡d¡¡d¡¡A¡¡d¡¡j¡¡u¡¡s¡¡t¡¡m¡¡e¡¡n¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡£©¡¡¡¡¡¡

removeAdjustmentListener£¨¡¡£©¡¡¡¡



C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Button£»¡¡Canvas£»¡¡¡¡

C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡Checkbox¡¡£»¡¡Choice£»¡¡Container¡¡£»¡¡Panel¡¡£»¡¡Applet¡¡£»¡¡ScrollPane£»¡¡¡¡

a¡¡d¡¡d¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡¡¡£©¡¡¡¡¡¡Window¡¡£»¡¡Dialog¡¡£»¡¡FileDialog£»¡¡Frame¡¡£»¡¡Label£»¡¡List¡¡£»¡¡Scrollbar£»¡¡¡¡

removeponentListener£¨¡¡¡¡£©¡¡¡¡T¡¡e¡¡x¡¡t¡¡A¡¡r¡¡e¡¡a¡¡£»¡¡¡¡and¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡



C¡¡o¡¡n¡¡t¡¡a¡¡i¡¡n¡¡e¡¡r¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡n¡¡t¡¡a¡¡i¡¡n¡¡e¡¡r¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Panel¡¡£»¡¡Applet¡¡£»¡¡¡¡

C¡¡o¡¡n¡¡t¡¡a¡¡i¡¡n¡¡e¡¡r¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡S¡¡c¡¡r¡¡o¡¡l¡¡l¡¡P¡¡a¡¡n¡¡e¡¡£»¡¡W¡¡i¡¡n¡¡d¡¡o¡¡w¡¡£»¡¡D¡¡i¡¡a¡¡l¡¡o¡¡g¡¡£»¡¡F¡¡i¡¡l¡¡e¡¡D¡¡i¡¡a¡¡l¡¡o¡¡g¡¡£»¡¡¡¡and¡¡Frame¡¡¡¡

a¡¡d¡¡d¡¡C¡¡o¡¡n¡¡t¡¡a¡¡i¡¡n¡¡e¡¡r¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡¡¡£©¡¡¡¡¡¡

removeContainerListener£¨¡¡¡¡£©¡¡¡¡¡¡



F¡¡o¡¡c¡¡u¡¡s¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Button£»¡¡Canvas£»¡¡¡¡

F¡¡o¡¡c¡¡u¡¡s¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Checkbox¡¡£»¡¡Choice£»¡¡Container¡¡£»¡¡Panel¡¡£»¡¡Applet¡¡£»¡¡ScrollPane£»¡¡¡¡

a¡¡d¡¡d¡¡F¡¡o¡¡c¡¡u¡¡s¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡Window¡¡£»¡¡Dialog¡¡£»¡¡FileDialog£»¡¡Frame¡¡¡¡Label£»¡¡List¡¡£»¡¡Scrollbar£»¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡F¡¡o¡¡c¡¡u¡¡s¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡T¡¡e¡¡x¡¡t¡¡A¡¡r¡¡e¡¡a¡¡£»¡¡¡¡and¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡



K¡¡e¡¡y¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Button£»¡¡Canvas£»¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡410¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡412¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

K¡¡e¡¡y¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Checkbox¡¡£»¡¡Choice£»¡¡Container¡¡£»¡¡Panel¡¡£»¡¡Applet¡¡£»¡¡ScrollPane£»¡¡¡¡

a¡¡d¡¡d¡¡K¡¡e¡¡y¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Window¡¡£»¡¡Dialog¡¡£»¡¡FileDialog£»¡¡Frame¡¡£»¡¡Label£»¡¡List¡¡£»¡¡Scrollbar£»¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡K¡¡e¡¡y¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡¡¡¡¡T¡¡e¡¡x¡¡t¡¡A¡¡r¡¡e¡¡a¡¡£»¡¡¡¡and¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡



M¡¡o¡¡u¡¡s¡¡e¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡£¨for¡¡both¡¡clicks¡¡and¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Button£»¡¡Canvas£»¡¡¡¡

motion£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Checkbox¡¡£»¡¡Choice£»¡¡Container¡¡£»¡¡Panel¡¡£»¡¡Applet¡¡£»¡¡ScrollPane£»¡¡¡¡

M¡¡o¡¡u¡¡s¡¡e¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Window¡¡£»¡¡Dialog¡¡£»¡¡FileDialog£»¡¡Frame¡¡£»¡¡Label£»¡¡List¡¡£»¡¡Scrollbar£»¡¡¡¡

a¡¡d¡¡d¡¡M¡¡o¡¡u¡¡s¡¡e¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡¡¡£©¡¡¡¡¡¡¡¡¡¡¡¡T¡¡e¡¡x¡¡t¡¡A¡¡r¡¡e¡¡a¡¡£»¡¡¡¡and¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡M¡¡o¡¡u¡¡s¡¡e¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡



M¡¡o¡¡u¡¡s¡¡e¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£§55£§¡¡¡¡£¨for¡¡both¡¡clicks¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Button£»¡¡Canvas£»¡¡¡¡

and¡¡motion£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Checkbox¡¡£»¡¡Choice£»¡¡Co¡¡ntainer¡¡£»¡¡Panel¡¡£»¡¡Applet¡¡£»¡¡ScrollPane£»¡¡¡¡

M¡¡o¡¡u¡¡s¡¡e¡¡M¡¡o¡¡t¡¡i¡¡o¡¡n¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡Window¡¡£»¡¡Dialog¡¡£»¡¡FileDialog£»¡¡Frame¡¡£»¡¡Label£»¡¡List¡¡£»¡¡Scrollbar£»¡¡¡¡

addMouseMotionListener£¨¡¡¡¡£©¡¡¡¡T¡¡e¡¡x¡¡t¡¡A¡¡r¡¡e¡¡a¡¡£»¡¡¡¡¡¡and¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡

removeMouseMotionListener£¨¡¡£©¡¡¡¡



W¡¡i¡¡n¡¡d¡¡o¡¡w¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Window¡¡and¡¡its¡¡derivatives£»¡¡including¡¡Dialog£»¡¡FileDialog£»¡¡and¡¡¡¡

W¡¡i¡¡n¡¡d¡¡o¡¡w¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡F¡¡r¡¡ame¡¡¡¡¡¡

a¡¡d¡¡d¡¡W¡¡i¡¡n¡¡d¡¡o¡¡w¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡W¡¡i¡¡n¡¡d¡¡o¡¡w¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡¡¡£©¡¡¡¡¡¡



I¡¡t¡¡e¡¡m¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Checkbox¡¡£»¡¡CheckboxMenuItem¡¡£»¡¡Choice¡¡£»¡¡List£»¡¡¡¡and¡¡anything¡¡that¡¡¡¡

I¡¡t¡¡e¡¡m¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implements¡¡the¡¡I¡¡t¡¡e¡¡m¡¡S¡¡e¡¡l¡¡e¡¡c¡¡t¡¡a¡¡b¡¡l¡¡e¡¡¡¡interface¡¡¡¡

a¡¡d¡¡d¡¡I¡¡t¡¡e¡¡m¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡I¡¡t¡¡e¡¡m¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡



T¡¡e¡¡x¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Anything¡¡derived¡¡from¡¡Textponent¡¡£»¡¡including¡¡TextArea¡¡¡¡and¡¡¡¡

T¡¡e¡¡x¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡

a¡¡d¡¡d¡¡T¡¡e¡¡x¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡

r¡¡e¡¡m¡¡o¡¡v¡¡e¡¡T¡¡e¡¡x¡¡t¡¡L¡¡i¡¡s¡¡t¡¡e¡¡n¡¡e¡¡r¡¡£¨¡¡¡¡£©¡¡¡¡¡¡



¡¡¡¡

¡¡¡¡

¢Ý£º¼´Ê¹±íÃæÉÏÈç´Ë£¬µ«Êµ¼ÊÉϲ¢Ã»ÓÐMouseMotiionEvent¡¡£¨Êó±êÔ˶¯Ê¼þ£©¡£µ¥»÷ºÍÔ˶¯¶¼ºÏ³Éµ½¡¡

MouseEvent¡¡ÀËùÒÔ¡¡MouseEvent¡¡ÔÚ±í¸ñÖеÄÕâÖÖÁíÀàÐÐΪ²¢·ÇÒ»¸ö´íÎ󡣡¡¡¡

¡¡¡¡

¿ÉÒÔ¿´µ½£¬Ã¿ÖÖÀàÐ͵Ä×é¼þֻΪÌض¨ÀàÐ͵ÄʼþÌṩÁËÖ§³Ö¡£ÕâÓÐÖúÓÚÎÒÃÇ·¢ÏÖÓÉÿÖÖ×é¼þÖ§³ÖµÄʼþ£¬Èç¡¡

ϱíËùʾ£º¡¡¡¡

¡¡¡¡

×é¼þÀàÐÍ¡¡Ö§³ÖµÄʼþ¡¡¡¡

¡¡¡¡

¡¡¡¡



C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡¡¡¡¡t¡¡y¡¡p¡¡e¡¡¡¡¡¡¡¡E¡¡v¡¡e¡¡n¡¡t¡¡s¡¡¡¡s¡¡u¡¡p¡¡p¡¡o¡¡r¡¡t¡¡e¡¡d¡¡¡¡b¡¡y¡¡¡¡t¡¡h¡¡i¡¡s¡¡¡¡c¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡¡¡¡¡



A¡¡d¡¡j¡¡u¡¡s¡¡t¡¡a¡¡b¡¡l¡¡e¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡A¡¡d¡¡j¡¡u¡¡s¡¡t¡¡m¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



A¡¡p¡¡p¡¡l¡¡e¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Conta¡¡inerEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



B¡¡u¡¡t¡¡t¡¡o¡¡n¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActionEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



C¡¡a¡¡n¡¡v¡¡a¡¡s¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡F¡¡o¡¡c¡¡u¡¡s¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡K¡¡e¡¡y¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡M¡¡o¡¡u¡¡s¡¡e¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



C¡¡h¡¡e¡¡c¡¡k¡¡b¡¡o¡¡x¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ItemEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



CheckboxMenuItem¡¡A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡I¡¡t¡¡e¡¡m¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



C¡¡h¡¡o¡¡i¡¡c¡¡e¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ItemEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡F¡¡o¡¡c¡¡u¡¡s¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡K¡¡e¡¡y¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡M¡¡o¡¡u¡¡s¡¡e¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



C¡¡o¡¡n¡¡t¡¡a¡¡i¡¡n¡¡e¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ContainerEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡411¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡413¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

D¡¡i¡¡a¡¡l¡¡o¡¡g¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Co¡¡ntainerEvent£»¡¡WindowEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



F¡¡i¡¡l¡¡e¡¡D¡¡i¡¡a¡¡l¡¡o¡¡g¡¡¡¡¡¡¡¡¡¡¡¡¡¡ContainerEvent£»¡¡WindowEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



F¡¡r¡¡a¡¡m¡¡e¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ContainerEvent£»¡¡WindowEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



L¡¡a¡¡b¡¡e¡¡l¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡F¡¡o¡¡c¡¡u¡¡s¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡K¡¡e¡¡y¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡M¡¡o¡¡u¡¡s¡¡e¡¡E¡¡v¡¡e¡¡n¡¡t¡¡£»¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



L¡¡i¡¡s¡¡t¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActionEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ItemEvent£»¡¡ponentEvent¡¡¡¡



M¡¡e¡¡n¡¡u¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



M¡¡e¡¡n¡¡u¡¡I¡¡t¡¡e¡¡m¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡A¡¡c¡¡t¡¡i¡¡o¡¡n¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



P¡¡a¡¡n¡¡e¡¡l¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ContainerEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



P¡¡o¡¡p¡¡u¡¡p¡¡M¡¡e¡¡n¡¡u¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Act¡¡i¡¡o¡¡n¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



S¡¡c¡¡r¡¡o¡¡l¡¡l¡¡b¡¡a¡¡r¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡AdjustmentEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



S¡¡c¡¡r¡¡o¡¡l¡¡l¡¡P¡¡a¡¡n¡¡e¡¡¡¡¡¡¡¡¡¡¡¡¡¡ContainerEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



T¡¡e¡¡x¡¡t¡¡A¡¡r¡¡e¡¡a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡TextEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



T¡¡e¡¡x¡¡t¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡¡¡¡¡T¡¡e¡¡x¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡¡¡



T¡¡e¡¡x¡¡t¡¡F¡¡i¡¡e¡¡l¡¡d¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ActionEvent£»¡¡TextEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡ponentEvent¡¡¡¡



W¡¡i¡¡n¡¡d¡¡o¡¡w¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ContainerEvent£»¡¡WindowEvent£»¡¡FocusEvent£»¡¡KeyEvent£»¡¡MouseEvent£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡o¡¡m¡¡p¡¡o¡¡n¡¡e¡¡n¡¡t¡¡E¡¡v¡¡e¡¡n¡¡t¡¡¡¡¡¡



¡¡¡¡

¡¡¡¡

Ò»µ©ÖªµÀÁËÒ»¸öÌض¨µÄ×é¼þÖ§³ÖÄÄЩʼþ£¬¾Í²»±ØÔÙȥѰÕÒÈκζ«Î÷À´ÏìÓ¦ÄǸöʼþ¡£Ö»Ðè¼òµ¥µØ£º¡¡¡¡

¡¡£¨1£©¡¡È¡µÃʼþÀàµÄÃû×Ö£¬²¢É¾µôÆäÖеġ°Event¡±×ÖÑù¡£ÔÚʣϵIJ¿·Ö¼ÓÈë¡°Listener¡¡¡±×ÖÑù¡£Õâ¾ÍÊÇÔÚÎÒÃÇ¡¡

µÄÄÚ²¿ÀàÀïÐèҪʵÏֵĽÓÊÕÆ÷½Ó¿Ú¡£¡¡¡¡

¡¡£¨2£©¡¡ÊµÏÖÉÏÃæµÄ½Ó¿Ú£¬Õë¶ÔÏëÒª²¶»ñµÄʼþ±àд·½·¨´úÂë¡£ÀýÈ磬¼ÙÉèÎÒÃÇÏ벶»ñÊó±êµÄÒƶ¯£¬ËùÒÔÐèҪΪ¡¡

MouseMotiionListener¡¡½Ó¿ÚµÄ¡¡mouseMoved£¨£©·½·¨±àд´ú£¨µ±È»»¹±ØÐëʵÏÖÆäËûһЩ·½·¨£¬µ«ÕâÀïÓнݾ¶¿É¡¡

Ñ­£¬ÂíÉϾͻὲµ½Õâ¸öÎÊÌ⣩¡£¡¡¡¡

¡¡£¨3£©¡¡Îª²½Öè¡¡2¡¡ÖеĽÓÊÕÆ÷Àà´´½¨Ò»¸ö¶ÔÏó¡£Ëæ×Ô¼ºµÄ×é¼þºÍ·½·¨Íê³É¶ÔËüµÄ×¢²á£¬·½·¨ÊÇÔÚ½ÓÊÕÆ÷µÄÃû×ÖÀï¡¡

¼ÓÈëÒ»¸öǰ׺¡°add¡±¡£±ÈÈçaddMouseMotionListener£¨£©¡

·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨1£©

Äã¿ÉÄÜϲ»¶µÄ