{"id":862,"date":"2010-08-25T23:04:20","date_gmt":"2010-08-25T17:34:20","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=862"},"modified":"2010-08-25T23:04:20","modified_gmt":"2010-08-25T17:34:20","slug":"textbox-button-anonymous-actionlistner","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/textbox-button-anonymous-actionlistner\/","title":{"rendered":"Event Handling using Inner Class in Applet"},"content":{"rendered":"<p>We can handle the Event in Applet, AWT or Swing by following three different methods:<\/p>\n<ul>\n<li>Inner Class<\/li>\n<li>Anonymous class<\/li>\n<li>this Pointer<\/li>\n<\/ul>\n<p>In this example, i will show you that how to use inner classes to handle the events in Applet.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\npackage com.kunal.applet;\n\nimport java.applet.Applet;\nimport java.awt.Button;\nimport java.awt.TextField;\nimport java.awt.event.ActionEvent;\nimport java.awt.event.ActionListener;\n\npublic class InerClassButton extends Applet {\n\n TextField txtSource;\n Button btnLower,btnUpper;\n String lowerText=&quot;lower case&quot;;\n\n  public void init()\n  {\n     txtSource=new TextField(20);\n     btnLower=new Button(lowerText);\n     btnUpper=new Button(&quot;upper case&quot;);\n\n     btnLower.addActionListener(new MyActionListener());\n     btnUpper.addActionListener(new MyActionListener());\n\n     add(txtSource);\n     add(btnLower);\n     add(btnUpper);\n   }\n   class MyActionListener implements ActionListener\n   {\n    @Override\n     public void actionPerformed(ActionEvent evt) {\n     String tmp=txtSource.getText();\n     txtSource.setText(evt.getActionCommand()==lowerText?tmp.toLowerCase():tmp.toUpperCase());\n     }\n   }\n}\n<\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/08\/InnerClassButton.jpeg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-885\" title=\"Event Handling using Inner Class in Applet\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/08\/InnerClassButton.jpeg?resize=214%2C282&#038;ssl=1\" alt=\"Event Handling using Inner Class in Applet\" width=\"214\" height=\"282\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Demonstrates the example for handling event using Inner Class in Java Applet<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[41,92,329],"class_list":["post-862","post","type-post","status-publish","format-standard","hentry","category-java","tag-applet","tag-event-handling","tag-java"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":867,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/textbox-button-anonymous-actionlistener\/","url_meta":{"origin":862,"position":0},"title":"Event Handling using Anonymous Class in Applet","author":"Jitendra","date":"August 25, 2010","format":false,"excerpt":"Source code to demonstrate the usage of anonymous class in Applet","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Event Handling using Anonymous Class in Applet ","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/08\/AnonymousClass1.jpeg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":847,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/mouse-handling-in-applets-using-this\/","url_meta":{"origin":862,"position":1},"title":"Bouncing ball animation in Applet","author":"Jitendra","date":"August 25, 2010","format":false,"excerpt":"Example to show Bouncing ball animation in Applet","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Mouse handling in applets using this pointer method, Bouncing ball","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/08\/bOUNCINGBall.jpeg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":778,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/applet-lifecycle-of-applet\/","url_meta":{"origin":862,"position":2},"title":"Lifecycle of Applet","author":"Jitendra","date":"August 22, 2010","format":false,"excerpt":"Example which shows the lifecycle of applet","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":999,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/bouncing-ball-applet-create-balls-on-mouse-click-of-random-color-and-random-size\/","url_meta":{"origin":862,"position":3},"title":"Bouncing ball applet &#8211; Create Balls on Mouse click of random color and random size","author":"Jitendra","date":"September 9, 2010","format":false,"excerpt":"Creating the balls on mouse click of random color, random size and random speed and bouncing around the wall of applet in JAVA.","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Bouncing Ball applet - Create ball on Mouse click of random size and random color","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2010\/09\/Bouncing-Ball-applet.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1764,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/read-xml-file-using-sax-parser-in-java\/","url_meta":{"origin":862,"position":4},"title":"Read XML File using SAX Parser in JAVA","author":"Jitendra","date":"March 22, 2011","format":false,"excerpt":"Example of Reading XML File using SAX Parser in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"SAX Parser","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/SAX-Parser.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1571,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/snmp\/create-snmp-client-in-java-using-snmp4j\/","url_meta":{"origin":862,"position":5},"title":"Create SNMP Client in JAVA Using SNMP4j","author":"Jitendra","date":"February 23, 2011","format":false,"excerpt":"Create SNMP Client in JAVA Using SNMP4j","rel":"","context":"In &quot;SNMP&quot;","block_context":{"text":"SNMP","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/snmp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}