gdata.io.handleScriptLoaded({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$georss":"http://www.georss.org/georss","xmlns$thr":"http://purl.org/syndication/thread/1.0","xmlns$blogger":"http://schemas.google.com/blogger/2008","id":{"$t":"tag:blogger.com,1999:blog-913600556879440043"},"updated":{"$t":"2024-01-01T15:38:08.302+05:30"},"category":[{"term":"Data Structures"},{"term":"Vedic Mathematics"},{"term":"My Vlogs"},{"term":"Website Designing"},{"term":"Guest Blogging"},{"term":"Youtube"},{"term":"PPL"},{"term":"Android"},{"term":"Android App Development"},{"term":"High Performance Computing"},{"term":"Socket Programming"},{"term":"Java"},{"term":"Cloud Computing"},{"term":"Unboxing \u0026 Review"},{"term":"Database"},{"term":"OpenMPI"},{"term":"OPENCL"},{"term":"CUDA"},{"term":"LEX \u0026 YACC"},{"term":"Vocabulary"},{"term":"Compiler"},{"term":"Blogging Tips"},{"term":"Networking"},{"term":"Linux"},{"term":"Nanded City Pune"},{"term":"Parallel Computing"},{"term":"SDL"},{"term":"Fedora"},{"term":"Udemy Courses"},{"term":"Dia Software"},{"term":"MPI"},{"term":"Multithreading"},{"term":"Computer Networks"},{"term":"Abbreviations in Computer Science"},{"term":"Salesforce"},{"term":"Lisp"},{"term":"YouTube Tips"},{"term":"MS Excel Formulas \u0026 Functions"},{"term":"C Plus Plus Programming"},{"term":"GATE"},{"term":"Mysql"},{"term":"Google Forms"},{"term":"Wine"},{"term":"Swing"},{"term":"Mathematics"},{"term":"SQL"},{"term":"Amazon Links Summary"},{"term":"Thread Pool"},{"term":"General"},{"term":"Amazon Affiliate Program"},{"term":"How To Write Blog"},{"term":"C Programming"},{"term":"Applet"},{"term":"Selenium Automation Testing"},{"term":"Skill Development Lab"},{"term":"OPENMP"},{"term":"Python"},{"term":"Ubuntu"}],"title":{"type":"text","$t":"Computer Revolution (www.comrevo.com)"},"subtitle":{"type":"html","$t":""},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/-/Swing?alt\u003djson-in-script\u0026max-results\u003d6"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/-/Swing?alt\u003djson-in-script\u0026max-results\u003d6"},{"rel":"alternate","type":"text/html","href":"http://www.comrevo.com/search/label/Swing"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"},{"rel":"next","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/-/Swing/-/Swing?alt\u003djson-in-script\u0026start-index\u003d7\u0026max-results\u003d6"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"generator":{"version":"7.00","uri":"https://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"10"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"6"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-446577838238300408"},"published":{"$t":"2020-10-07T13:04:00.006+05:30"},"updated":{"$t":"2020-10-07T13:07:33.454+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"How To Add Image in Java Swing JFrame using JLabel"},"content":{"type":"html","$t":"\u003cp\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cspan\u003eIn this post, we will see How To Add Image in Java Swing JFrame using JLabel.\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\u003ca name\u003d'more'\u003e\u003c/a\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan\u003e\u003cb\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003eTo know\u0026nbsp;\u003cb\u003ewhat is Swing, how Swing is different from Applet, how to create Swing Application\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/swing-in-java-with-example.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/swing-in-java-with-example.html\u003c/a\u003e\u003cb\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003cbr /\u003e\u003cspan\u003e\u003cspan\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To know\u0026nbsp;\u003cb\u003ehow to generate event in Java Swing along with Java Swing program for addition of two numbers\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\u003c/a\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\u003cspan\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\u003cspan\u003e\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Here, we will see Java Swing program for adding Image on frame.\u003c/span\u003e\u003cspan\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In Swing, there are different ways to add image on frame e.g. using paint() method or using JPanel class.\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cdiv\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; But, the best way to add image is by using \u003cb\u003eJLabel \u003c/b\u003eclass. We need to create JLabel object. While creating JLabel object, we need to pass object of \u003cb\u003eImageIcon\u003c/b\u003e class. While creating object of ImageIcon, we need to pass object of \u003cb\u003eBufferedImage\u003c/b\u003e class. To create object of BufferedImage, we need to call \u003cb\u003eread()\u003c/b\u003e method of \u003cb\u003eImageIO\u003c/b\u003e class. We have to pass object of \u003cb\u003eFile\u003c/b\u003e class into read() method as parameter. File object\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan\u003erefers our \u003cb\u003eimage file\u003c/b\u003e.\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan\u003e\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Go through the following program:\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\u003cspan\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cspan\u003e\u003cbr /\u003e\u003c/span\u003e\u003cbr /\u003e\u003c/span\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"orphans: auto; widows: 1;\" trbidi\u003d\"on\"\u003e\u003cdiv style\u003d\"font-family: \u0026quot;times new roman\u0026quot;;\"\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan\u003e\u003cb\u003eProgram (SwingImage.java):\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\u003c/span\u003e\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eimport javax.swing.*;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.*;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.image.BufferedImage;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eimport java.io.File;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eimport javax.imageio.ImageIO;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003epublic class SwingImage\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;public static void main(String args[]) throws Exception\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Abc obj\u003dnew Abc();\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eclass Abc extends JFrame\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; public Abc() throws Exception\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setLayout(new FlowLayout());\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l1\u003dnew JLabel(\"Full Name:\");\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t1\u003dnew JTextField();\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;t1.setColumns(20);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l2\u003dnew JLabel(\"Class:\");\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t2\u003dnew JTextField();\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;t2.setColumns(20);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l3\u003dnew JLabel(\"College:\");\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t3\u003dnew JTextField();\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;t3.setColumns(20);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l4\u003dnew JLabel(\"City\");\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t4\u003dnew JTextField();\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;t4.setColumns(20);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JButton b1\u003dnew JButton(\"Submit\");\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JButton b2\u003dnew JButton(\"Reset\");\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l1);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t1);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l2);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t2);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l3);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t3);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l4);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t4);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(b1);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(b2);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;BufferedImage myPicture \u003d ImageIO.read(new File(\"thread life cycle.jpeg\"));\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel picLabel \u003d new JLabel(new ImageIcon(myPicture));\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(picLabel);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan\u003e\u0026nbsp;\u003c/span\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setVisible(true);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setSize(250,400);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e}\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003c/div\u003e\u003cdiv\u003e\u003c/div\u003e\u003c/div\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb style\u003d\"font-family: \u0026quot;Times New Roman\u0026quot;; widows: 2;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eHow To Run:\u003c/span\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan\u003e\u003cspan\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan\u003eparag@parag-Inspiron-N4010:~/Desktop/prog/swing$ javac SwingImage.java\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan\u003eparag@parag-Inspiron-N4010:~/Desktop/prog/swing$ java SwingImage\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cbr /\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv\u003e\u003c/div\u003e\u003cdiv\u003e\u003c/div\u003e\u003c/div\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cbr /\u003e\u003c/div\u003e\u003cspan style\u003d\"font-family: \u0026quot;Times New Roman\u0026quot;; widows: 2;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr style\u003d\"font-family: \u0026quot;Times New Roman\u0026quot;; widows: 2;\" /\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003e\u003cbr /\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eOutput:\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\u003ca href\u003d\"https://1.bp.blogspot.com/-shlHQWwEUjg/X31uCzSxI8I/AAAAAAAAEgU/wYYYTu1PR30NYbnP-SR6tiIRxf2ZBFsrACNcBGAsYHQ/s490/SwingImage.png\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"490\" data-original-width\u003d\"243\" src\u003d\"https://1.bp.blogspot.com/-shlHQWwEUjg/X31uCzSxI8I/AAAAAAAAEgU/wYYYTu1PR30NYbnP-SR6tiIRxf2ZBFsrACNcBGAsYHQ/s16000/SwingImage.png\" /\u003e\u003c/a\u003e\u003c/div\u003e\u003cbr /\u003e\u003cb\u003e\u003cbr /\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003cb\u003eCheck other posts on Java Programming in this link\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-programming.html\"\u003ehttp://www.comrevo.com/2017/08/java-programming.html\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comrevo.com/feeds/446577838238300408/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comrevo.com/2020/10/how-to-add-image-in-java-swing-jframe-using-jlabel.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/446577838238300408"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/446577838238300408"},{"rel":"alternate","type":"text/html","href":"https://www.comrevo.com/2020/10/how-to-add-image-in-java-swing-jframe-using-jlabel.html","title":"How To Add Image in Java Swing JFrame using JLabel"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://1.bp.blogspot.com/-shlHQWwEUjg/X31uCzSxI8I/AAAAAAAAEgU/wYYYTu1PR30NYbnP-SR6tiIRxf2ZBFsrACNcBGAsYHQ/s72-c/SwingImage.png","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-18634362289179253"},"published":{"$t":"2018-09-11T11:52:00.002+05:30"},"updated":{"$t":"2020-10-14T20:06:52.270+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"Java Swing Multi Frame Example | Swing Trading Multiple Time Frames | Java Swing Multiple Windows"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003cbr /\u003e\n\u003cb style\u003d\"font-size: x-large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003e\u003cspan style\u003d\"font-size: large;\"\u003eIn this post, we will see Java Swing Multi Frame Example | Swing Trading Multiple Time Frames | Java Swing Multiple Windows.\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eWatch following video:\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\n  \n  \u003ciframe allow\u003d\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003d\"\" frameborder\u003d\"0\" height\u003d\"360\" src\u003d\"https://www.youtube.com/embed/lbirAW1jDN4\" width\u003d\"640\"\u003e\u003c/iframe\u003e\n  \n  \n  \u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003e\u003cbr /\u003e\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eWatch on YouTube:\u0026nbsp;\u003ca href\u003d\"https://www.youtube.com/watch?v\u003dlbirAW1jDN4\" target\u003d\"_blank\"\u003ehttps://www.youtube.com/watch?v\u003dlbirAW1jDN4\u003c/a\u003e\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Go through the following program.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003ca name\u003d'more'\u003e\u003c/a\u003e\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cb style\u003d\"font-size: x-large;\"\u003eProgram (\u003c/b\u003e\u003cb\u003e\u003cspan style\u003d\"font-size: large;\"\u003eSwingMultiFrame\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e.java)\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport javax.swing.*;\u003cbr /\u003eimport java.awt.*;\u003cbr /\u003eimport java.awt.event.*;\u003cbr /\u003e\u003cbr /\u003epublic class SwingMultiFrame\u003cbr /\u003e{\u003cbr /\u003e\u0026nbsp; public static void main(String args[])\u003cbr /\u003e\u0026nbsp;\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; Frame1 obj1\u003dnew Frame1();\u003cbr /\u003e\u0026nbsp;\u0026nbsp; }\u003cbr /\u003e}\u003cbr /\u003e\u003cbr /\u003eclass Frame1 extends JFrame implements ActionListener\u003cbr /\u003e{\u003cbr /\u003e\u0026nbsp; JButton b\u003dnew JButton(\"New Frame\");\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp; public Frame1()\u003cbr /\u003e\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setVisible(true);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setSize(250,400);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setLayout(new FlowLayout());\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; add(b);\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; b.addActionListener(this);\u003cbr /\u003e\u0026nbsp; }\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp; public void actionPerformed(ActionEvent ae)\u003cbr /\u003e\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; Frame2 obj2\u003dnew Frame2();\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; //dispose();\u003cbr /\u003e\u0026nbsp; }\u003cbr /\u003e}\u003cbr /\u003e\u003cbr /\u003e\u003cbr /\u003eclass Frame2 extends JFrame\u003cbr /\u003e{\u003cbr /\u003e\u0026nbsp; public Frame2()\u003cbr /\u003e\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp; setVisible(true);\u003cbr /\u003e\u0026nbsp;\u0026nbsp; setSize(250,400);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003cbr /\u003e\u0026nbsp;\u0026nbsp; setLayout(new FlowLayout());\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp;\u0026nbsp; JLabel l1\u003dnew JLabel(\"Welcome To New Frame\");\u003cbr /\u003e\u0026nbsp;\u0026nbsp; add(l1);\u003cbr /\u003e\u0026nbsp; }\u003cbr /\u003e}\u003c/span\u003e\u003cbr /\u003e\n\u003cbr /\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cb style\u003d\"font-family: \u0026quot;times new roman\u0026quot;; font-size: x-large;\"\u003eHow To Run on Terminal:\u0026nbsp;\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/swing$ javac\u0026nbsp;SwingMultiFrame.java\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/swing$ java\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eSwingMultiFrame\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003cbr /\u003e\u003c/div\u003e\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cb\u003e\u003cspan style\u003d\"font-size: large;\"\u003eOutput:\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-91-KfXO6VEI/XVYtyK8nVOI/AAAAAAAAECc/b824yQbK8s0ocmEIKi2FXJhZ7sjAv0nugCLcBGAs/s1600/SwingMultiFrame.png\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"517\" data-original-width\u003d\"390\" src\u003d\"https://1.bp.blogspot.com/-91-KfXO6VEI/XVYtyK8nVOI/AAAAAAAAECc/b824yQbK8s0ocmEIKi2FXJhZ7sjAv0nugCLcBGAs/s1600/SwingMultiFrame.png\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cu\u003e\u003cb\u003eNote:\u003c/b\u003e\u003c/u\u003e\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; If you wish that first frame should get disappeared when second frame appear on screen, then call \u003cb\u003edispose()\u003c/b\u003e method after creating object of Frame2.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; If you want that after clicking on \u003cb\u003eCROSS\u003c/b\u003e button on second frame, \u003cu\u003efirst frame should remain on screen\u003c/u\u003e, then remove statement \u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003esetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); from the constructor of Frame2.\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; While if you want that after clicking on \u003cb\u003eCROSS\u003c/b\u003e button of first frame, \u003cu\u003esecond frame should remain on screen\u003c/u\u003e, then remove \u003c/span\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003esetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); from the constructor of Frame1.\u003c/span\u003e\u0026nbsp;\u003c/span\u003e \u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comrevo.com/feeds/18634362289179253/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comrevo.com/2018/09/swing-multi-frame-example.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/18634362289179253"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/18634362289179253"},{"rel":"alternate","type":"text/html","href":"https://www.comrevo.com/2018/09/swing-multi-frame-example.html","title":"Java Swing Multi Frame Example | Swing Trading Multiple Time Frames | Java Swing Multiple Windows"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://i.ytimg.com/vi/lbirAW1jDN4/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-4080664843726911068"},"published":{"$t":"2018-09-07T11:52:00.001+05:30"},"updated":{"$t":"2020-10-29T23:08:02.662+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"Java Swing Menu Bar | Menu Bar in Java Swing Example | Java Swing JMenuBar, JMenu, JMenuItem"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003cb style\u003d\"font-size: x-large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u003c/b\u003e\u003cspan style\u003d\"font-size: large;\"\u003eIn this post, we will see Java Swing Menu Bar | Menu Bar in Java Swing Example | Java Swing JMenuBar, JMenu, JMenuItem.\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eWatch following video:\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\n  \n  \u003ciframe width\u003d\"640\" height\u003d\"360\" src\u003d\"https://www.youtube.com/embed/4VqnSgB1fOs\" frameborder\u003d\"0\" allow\u003d\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\u003c/iframe\u003e\n  \n  \n  \n  \u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eWatch on YouTube:\u0026nbsp;\u003ca href\u003d\"https://www.youtube.com/watch?v\u003d4VqnSgB1fOs\" target\u003d\"_blank\"\u003ehttps://www.youtube.com/watch?v\u003d4VqnSgB1fOs\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Go through the following program.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003ca name\u003d'more'\u003e\u003c/a\u003e\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cb style\u003d\"font-size: x-large;\"\u003eProgram (\u003c/b\u003e\u003cb\u003e\u003cspan style\u003d\"font-size: large;\"\u003eSwingMenu\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e.java)\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;import javax.swing.*;\u003cbr /\u003eimport java.awt.*;\u003cbr /\u003eimport java.awt.event.*;\u003cbr /\u003e\u003cbr /\u003epublic class SwingMenu\u003cbr /\u003e{\u003cbr /\u003epublic static void main(String args[])\u003cbr /\u003e\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp; Abc obj\u003dnew Abc();\u003cbr /\u003e\u0026nbsp; }\u003cbr /\u003e}\u003cbr /\u003e\u003cbr /\u003eclass Abc extends JFrame implements ActionListener\u003cbr /\u003e{\u003cbr /\u003e\u0026nbsp; JMenuBar mb\u003dnew JMenuBar();\u003cbr /\u003e\u0026nbsp; JMenu m1\u003dnew JMenu(\"File\");\u003cbr /\u003e\u0026nbsp; JMenu m2\u003dnew JMenu(\"Edit\");\u003cbr /\u003e\u0026nbsp; JMenu m3\u003dnew JMenu(\"Help\");\u003cbr /\u003e\u0026nbsp; JMenuItem mi1\u003dnew JMenuItem(\"Cut\");\u003cbr /\u003e\u0026nbsp; JMenuItem mi2\u003dnew JMenuItem(\"Copy\");\u003cbr /\u003e\u0026nbsp; JMenuItem mi3\u003dnew JMenuItem(\"Paste\");\u003cbr /\u003e\u0026nbsp; JMenuItem mi4\u003dnew JMenuItem(\"Select All\");\u003cbr /\u003e\u0026nbsp; JTextArea ta\u003dnew JTextArea(20,20);\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp; public Abc()\u003cbr /\u003e\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setVisible(true);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setSize(250,400);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; setLayout(new FlowLayout());\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; add(mb);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mb.add(m1);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mb.add(m2);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mb.add(m3);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; m2.add(mi1);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; m2.add(mi1);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; m2.add(mi2);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; m2.add(mi3);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; m2.add(mi4);\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; add(ta);\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mi1.addActionListener(this);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mi2.addActionListener(this);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mi3.addActionListener(this);\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp; mi4.addActionListener(this);\u003cbr /\u003e\u0026nbsp; }\u003cbr /\u003e\u003cbr /\u003e\u0026nbsp; public void actionPerformed(ActionEvent e)\u003cbr /\u003e\u0026nbsp;\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; if(e.getSource()\u003d\u003dmi1)\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; ta.cut();\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; }\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; if(e.getSource()\u003d\u003dmi2)\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; ta.copy();\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; }\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; if(e.getSource()\u003d\u003dmi3)\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; { \u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; ta.paste();\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; }\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; if(e.getSource()\u003d\u003dmi4)\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; {\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; ta.selectAll();\u003cbr /\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; }\u003cbr /\u003e\u0026nbsp;\u0026nbsp; }\u003cbr /\u003e} \u003c/span\u003e\u003cbr /\u003e\n\u003cbr /\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cb style\u003d\"font-family: \u0026quot;times new roman\u0026quot;; font-size: x-large;\"\u003eHow To Run:\u0026nbsp;\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/swing$ javac SwingMenu.java\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/swing$ java SwingMenu\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003cbr /\u003e\u003c/div\u003e\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eOutput:\u003c/b\u003e\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-Fgi9GkN-1QM/XVY8zdAoOVI/AAAAAAAAECo/Huz8LCpTSjopdyEaAVndyeUmXDyT5dWaACLcBGAs/s1600/SwingMenu1.png\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"401\" data-original-width\u003d\"248\" src\u003d\"https://1.bp.blogspot.com/-Fgi9GkN-1QM/XVY8zdAoOVI/AAAAAAAAECo/Huz8LCpTSjopdyEaAVndyeUmXDyT5dWaACLcBGAs/s1600/SwingMenu1.png\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cbr /\u003e\n\u003cb\u003e\u003cspan style\u003d\"font-size: large;\"\u003eAfter Edit -\u0026gt; Select All -\u0026gt; Copy -\u0026gt; Paste\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-jjbtfrM2NM8/XVY9MymUwmI/AAAAAAAAECw/mH3RUqFni_AHHM7UGO3-O1RrzDhFnLh1wCLcBGAs/s1600/SwingMenu2.png\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"400\" data-original-width\u003d\"250\" src\u003d\"https://1.bp.blogspot.com/-jjbtfrM2NM8/XVY9MymUwmI/AAAAAAAAECw/mH3RUqFni_AHHM7UGO3-O1RrzDhFnLh1wCLcBGAs/s1600/SwingMenu2.png\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp; \u003c/span\u003e\u003c/div\u003e\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comrevo.com/feeds/4080664843726911068/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comrevo.com/2018/09/java-swing-menu-bar-example.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/4080664843726911068"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/4080664843726911068"},{"rel":"alternate","type":"text/html","href":"https://www.comrevo.com/2018/09/java-swing-menu-bar-example.html","title":"Java Swing Menu Bar | Menu Bar in Java Swing Example | Java Swing JMenuBar, JMenu, JMenuItem"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://i.ytimg.com/vi/4VqnSgB1fOs/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-4710655083039408566"},"published":{"$t":"2018-09-07T11:34:00.003+05:30"},"updated":{"$t":"2020-10-28T18:45:59.378+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"Java Swing Mouse Motion Listener With Program in Java | MouseMotionListener Interface and Methods"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eJava Swing Mouse Motion Listener With Program in Java | MouseMotionListener Interface and Methods.\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In previous post, we have seen use of Java Swing MouseListener interface. Check here\u0026nbsp;\u003ca href\u003d\"https://www.comrevo.com/2017/08/java-swing-mouselistener-example.html\" target\u003d\"_blank\"\u003ehttps://www.comrevo.com/2017/08/java-swing-mouselistener-example.html\u003c/a\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003ca name\u003d'more'\u003e\u003c/a\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eWatch following video:\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\n  \n  \u003ciframe width\u003d\"640\" height\u003d\"360\" src\u003d\"https://www.youtube.com/embed/zcyYyFnvybg\" frameborder\u003d\"0\" allow\u003d\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\u003c/iframe\u003e\n  \n  \n  \u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eWatch on YouTube:\u0026nbsp;\u003ca href\u003d\"https://www.youtube.com/watch?v\u003dzcyYyFnvybg\" target\u003d\"_blank\"\u003ehttps://www.youtube.com/watch?v\u003dzcyYyFnvybg\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003e\u003cbr /\u003e\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eHow to use MouseMotionListener interface?\u003c/b\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Use of MouseMotionListener interface in Java Swing is similar to MouseListener inteface. Only the difference is in the methods used.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To generate event, we have to register component (button or label or textfield etc.) for event by calling method\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eaddMouseMotionListener(). This method accepts object of\u0026nbsp;MouseMotionListener\u0026nbsp;interface. As we can not create object of interface, we have to\u0026nbsp;implement\u0026nbsp;MouseMotionListener\u0026nbsp;interface into class and we need to pass object of this class to\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eaddMouseMotionListener()\u0026nbsp;method as argument.\u0026nbsp;\u003cb\u003ethis\u003c/b\u003e\u0026nbsp;represents the current object of class.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eaddMouseMotionListener()\u0026nbsp;implicitly\u0026nbsp;call methods mouseDragged(), mouseMoved()\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;depending on mouse action\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e. These methods accepts object of\u0026nbsp;MouseEvent\u0026nbsp;class as argument. These\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;methods are declared in\u0026nbsp;MouseMotionListener\u0026nbsp;interface. Whatever the action we have to take for event, we have to mention in these methods.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/span\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Go through the following program:\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cb style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eSwingMouseMotionListener.java\u0026nbsp;\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eimport javax.swing.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.event.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003epublic class SwingMouseMotionListener\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;public static void main(String args[])\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Abc obj\u003dnew Abc();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eclass Abc extends JFrame implements MouseMotionListener\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; JLabel l1,l2,l3;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; public Abc()\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setLayout(new FlowLayout());\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l1\u003dnew JLabel(\"Mouse Action\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l2\u003dnew JLabel(\"Mouse Cursor Position:\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l3\u003dnew JLabel(\"Take Mouse Cursor Here\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l1);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l2);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l3);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l3.addMouseMotionListener(this);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setVisible(true);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setSize(250,300);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mouseDragged(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Dragged\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mouseMoved(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Moved\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cbr /\u003e\n\u003cdiv dir\u003d\"ltr\" style\u003d\"orphans: auto; text-align: left; text-indent: 0px; widows: 1;\" trbidi\u003d\"on\"\u003e\n\u003cdiv style\u003d\"font-family: \u0026quot;times new roman\u0026quot;;\"\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eHow To Run:\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/prog$ javac SwingMouseMotionListener.java\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/prog$ java SwingMouseMotionListener\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eOutput:\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-lrzR0r13oAU/WZ0Kpsa5RNI/AAAAAAAADoU/z2FxV8j-XHg7nLVBlqDLwOa1szvkMYRmQCLcBGAs/s1600/MouseListener.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"327\" data-original-width\u003d\"247\" src\u003d\"https://1.bp.blogspot.com/-lrzR0r13oAU/WZ0Kpsa5RNI/AAAAAAAADoU/z2FxV8j-XHg7nLVBlqDLwOa1szvkMYRmQCLcBGAs/s1600/MouseListener.jpeg\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large; text-align: center;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;When Mouse Cursor is Dragged over Label \"Take Mouse Cursor Here\" (i.e. Mouse button is pressed and cursor is moved):\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://3.bp.blogspot.com/-ACvJgQQe3uI/W5ITFQcnf5I/AAAAAAAAD2k/0sOQha4Rd1cbmpT6uN97g0PSjw1m3TMngCLcBGAs/s1600/mouseDragged.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"457\" data-original-width\u003d\"350\" height\u003d\"400\" src\u003d\"https://3.bp.blogspot.com/-ACvJgQQe3uI/W5ITFQcnf5I/AAAAAAAAD2k/0sOQha4Rd1cbmpT6uN97g0PSjw1m3TMngCLcBGAs/s400/mouseDragged.jpeg\" width\u003d\"305\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;When Mouse Cursor is moved over Label \"Take Mouse Cursor Here\" (without pressing Mouse button):\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://3.bp.blogspot.com/-vuXOQzLFYDo/W5ITo8Pwe3I/AAAAAAAAD2s/wwocQpflv0w2DWkKYvMKWMAgB-P4UQeGACLcBGAs/s1600/mouseMoved.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"454\" data-original-width\u003d\"345\" height\u003d\"400\" src\u003d\"https://3.bp.blogspot.com/-vuXOQzLFYDo/W5ITo8Pwe3I/AAAAAAAAD2s/wwocQpflv0w2DWkKYvMKWMAgB-P4UQeGACLcBGAs/s400/mouseMoved.jpeg\" width\u003d\"303\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cb style\u003d\"font-size: x-large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u003c/b\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb style\u003d\"font-size: x-large;\"\u003e\u0026nbsp; \u003c/b\u003e\u003cspan style\u003d\"font-size: large;\"\u003eTo know\u0026nbsp;\u003c/span\u003e\u003cb style\u003d\"font-size: x-large;\"\u003ewhat is Swing, how Swing is different from Applet, how to create Swing Application\u003c/b\u003e\u003cspan style\u003d\"font-size: large;\"\u003e; check this post\u0026nbsp;\u003c/span\u003e\u003ca href\u003d\"http://www.comrevo.com/2017/08/swing-in-java-with-example.html\" style\u003d\"font-size: x-large;\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/swing-in-java-with-example.html\u003c/a\u003e\u003cb style\u003d\"font-size: x-large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv style\u003d\"font-family: \u0026quot;Times New Roman\u0026quot;;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To know\u0026nbsp;\u003cb\u003ehow to generate event in Java Swing along with Java Swing program for addition of two numbers\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\u003c/a\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Find\u0026nbsp;\u003cb\u003eJava Swing program for Calculator\u003c/b\u003e\u0026nbsp;in this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-swing-calculator-program.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/java-swing-calculator-program.html\u003c/a\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eFind\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"background-color: #fefdfa; font-family: \u0026quot;georgia\u0026quot; , \u0026quot;utopia\u0026quot; , \u0026quot;palatino linotype\u0026quot; , \u0026quot;palatino\u0026quot; , serif;\"\u003e\u003cb\u003eJava Swing MouseListener Example\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003ein this post\u0026nbsp;\u003ca href\u003d\"https://www.comrevo.com/2017/08/java-swing-mouselistener-example.html\" target\u003d\"_blank\"\u003ehttps://www.comrevo.com/2017/08/java-swing-mouselistener-example.html\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003cb\u003eCheck other posts on Java Programming in this link\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-programming.html\"\u003ehttp://www.comrevo.com/2017/08/java-programming.html\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comrevo.com/feeds/4710655083039408566/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comrevo.com/2018/09/java-swing-mouse-motion-listener-example.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/4710655083039408566"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/4710655083039408566"},{"rel":"alternate","type":"text/html","href":"https://www.comrevo.com/2018/09/java-swing-mouse-motion-listener-example.html","title":"Java Swing Mouse Motion Listener With Program in Java | MouseMotionListener Interface and Methods"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://i.ytimg.com/vi/zcyYyFnvybg/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-1829550244252789390"},"published":{"$t":"2017-08-23T09:57:00.002+05:30"},"updated":{"$t":"2020-10-28T18:42:30.194+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"Java Swing Mouse Listener | MouseListener in Java Swing Example | MouseListener Interface in Java"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see Java Swing Mouse Listener | MouseListener in Java Swing Example | MouseListener Interface in Java.\u003c/span\u003e\u003cbr /\u003e\n\u003ca name\u003d'more'\u003e\u003c/a\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eWatch following video:\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\n  \n  \u003ciframe allow\u003d\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003d\"\" frameborder\u003d\"0\" height\u003d\"360\" src\u003d\"https://www.youtube.com/embed/M1BF8kFQV_0\" width\u003d\"640\"\u003e\u003c/iframe\u003e\n  \n  \n  \n  \u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eWatch on YouTube:\u0026nbsp;\u003ca href\u003d\"https://www.youtube.com/watch?v\u003dM1BF8kFQV_0\" target\u003d\"_blank\"\u003ehttps://www.youtube.com/watch?v\u003dM1BF8kFQV_0\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003e\u003cbr /\u003e\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eHow to use MouseListener interface?\u003c/b\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Use of MouseListener interface in Java Swing is similar to ActionListener inteface. Only the difference is in the names of methods used.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To generate event, we have to register component (button or label or textfield etc.) for event by calling method\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eaddMouseListener(). This method accepts object of\u0026nbsp;MouseListener\u0026nbsp;interface. As we can not create object of interface, we have to\u0026nbsp;implement\u0026nbsp;MouseListener\u0026nbsp;interface into class and we need to pass object of this class to\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eaddMouseListener()\u0026nbsp;method as argument. \u003cb\u003ethis\u003c/b\u003e represents the current object of class.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003eaddMouseListener()\u0026nbsp;implicitly\u0026nbsp;call methods\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003emousePressed(),\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003emouseReleased(),\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003emouseClicked(),\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003emouseEntered(),\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003emouseExited() depending on mouse action\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e. These methods accepts object of\u0026nbsp;MouseEvent\u0026nbsp;class as argument. These\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;methods are declared in\u0026nbsp;MouseListener\u0026nbsp;interface. Whatever the action we have to take for event, we have to mention in these methods.\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: medium;\"\u003e\u003cspan style\u003d\"font-size: medium;\"\u003e\u003c/span\u003e\u003c/span\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Go through the following program:\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cb style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eSwingMouseListener.java\u0026nbsp;\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport javax.swing.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.event.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003epublic class SwingMouseListener\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;public static void main(String args[])\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Abc obj\u003dnew Abc();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eclass Abc extends JFrame implements MouseListener\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; JLabel l1,l2,l3;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; public Abc()\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setLayout(new FlowLayout());\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l1\u003dnew JLabel(\"Mouse Action\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l2\u003dnew JLabel(\"Mouse Cursor Position:\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l3\u003dnew JLabel(\"Take Mouse Cursor Here\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l1);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l2);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l3);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l3.addMouseListener(this);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setVisible(true);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setSize(250,300);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mousePressed(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Pressed\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mouseReleased(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Released\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mouseClicked(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Clicked\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mouseEntered(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; { \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Entered\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void mouseExited(MouseEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int x\u003dae.getX();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;int y\u003dae.getY();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l1.setText(\"Mouse is Exited\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;l2.setText(\"Cursor Position: \"+x+\",\"+y);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cbr /\u003e\n\u003cdiv dir\u003d\"ltr\" style\u003d\"orphans: auto; text-align: left; text-indent: 0px; widows: 1;\" trbidi\u003d\"on\"\u003e\n\u003cdiv style\u003d\"font-family: \u0026quot;times new roman\u0026quot;;\"\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eHow To Run:\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/prog$ javac SwingMouseListener.java\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/prog$ java SwingMouseListener\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eOutput:\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-lrzR0r13oAU/WZ0Kpsa5RNI/AAAAAAAADoU/z2FxV8j-XHg7nLVBlqDLwOa1szvkMYRmQCLcBGAs/s1600/MouseListener.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"327\" data-original-width\u003d\"247\" src\u003d\"https://1.bp.blogspot.com/-lrzR0r13oAU/WZ0Kpsa5RNI/AAAAAAAADoU/z2FxV8j-XHg7nLVBlqDLwOa1szvkMYRmQCLcBGAs/s1600/MouseListener.jpeg\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large; text-align: center;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;When Mouse Cursor is taken to Label \"Take Mouse Cursor Here\":\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://2.bp.blogspot.com/-O_Ws5_B9Zhs/WZ0LCN3p9aI/AAAAAAAADoY/-VnZxV5PgB0um1u4ayZvkQn_rOX2NRtCACLcBGAs/s1600/MouseListenerEntered.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"327\" data-original-width\u003d\"249\" src\u003d\"https://2.bp.blogspot.com/-O_Ws5_B9Zhs/WZ0LCN3p9aI/AAAAAAAADoY/-VnZxV5PgB0um1u4ayZvkQn_rOX2NRtCACLcBGAs/s1600/MouseListenerEntered.jpeg\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;When Mouse Cursor is exited from Label \"Take Mouse Cursor Here\":\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://3.bp.blogspot.com/-WI4pkWW4NMo/WZ0LchGUpvI/AAAAAAAADoc/PD63jYHRHXgihg0kmzfbOBm8GbyUJixzQCLcBGAs/s1600/MouseListenerExited.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"328\" data-original-width\u003d\"249\" src\u003d\"https://3.bp.blogspot.com/-WI4pkWW4NMo/WZ0LchGUpvI/AAAAAAAADoc/PD63jYHRHXgihg0kmzfbOBm8GbyUJixzQCLcBGAs/s1600/MouseListenerExited.jpeg\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;When Mouse Cursor is pressed on Label \"Take Mouse Cursor Here\":\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-8V8k3JK0r0g/WZ0Lv61oDuI/AAAAAAAADog/tIc4-jOBc58PHEZyiZ34jw0GwEMp1FViQCLcBGAs/s1600/MouseListenerPressed.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"327\" data-original-width\u003d\"248\" src\u003d\"https://1.bp.blogspot.com/-8V8k3JK0r0g/WZ0Lv61oDuI/AAAAAAAADog/tIc4-jOBc58PHEZyiZ34jw0GwEMp1FViQCLcBGAs/s1600/MouseListenerPressed.jpeg\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;When Mouse Cursor is Clicked (i.e. Pressed \u0026amp; Released) on Label \"Take Mouse Cursor Here\":\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://3.bp.blogspot.com/-GZqqvUEaF_c/WZ0MHGyWADI/AAAAAAAADok/NNFVXg3rCakTNenQIMxdjnLtpAf4QT9tQCLcBGAs/s1600/MouseListenerClicked.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"327\" data-original-width\u003d\"249\" src\u003d\"https://3.bp.blogspot.com/-GZqqvUEaF_c/WZ0MHGyWADI/AAAAAAAADok/NNFVXg3rCakTNenQIMxdjnLtpAf4QT9tQCLcBGAs/s1600/MouseListenerClicked.jpeg\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp; Check Java Swing \u003cb\u003eMouseMotionListener\u003c/b\u003e Example in following post:\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003ca href\u003d\"https://www.comrevo.com/2018/09/java-swing-mouse-motion-listener-example.html\" target\u003d\"_blank\"\u003ehttps://www.comrevo.com/2018/09/java-swing-mouse-motion-listener-example.html\u003c/a\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cbr /\u003e\n\u003cdiv style\u003d\"font-family: \u0026quot;Times New Roman\u0026quot;;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003eTo know\u0026nbsp;\u003cb\u003ewhat is Swing, how Swing is different from Applet, how to create Swing Application\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/swing-in-java-with-example.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/swing-in-java-with-example.html\u003c/a\u003e\u003cb\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv style\u003d\"font-family: \u0026quot;Times New Roman\u0026quot;;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To know\u0026nbsp;\u003cb\u003ehow to generate event in Java Swing along with Java Swing program for addition of two numbers\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\u003c/a\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Find \u003cb\u003eJava Swing program for Calculator\u003c/b\u003e in this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-swing-calculator-program.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/java-swing-calculator-program.html\u003c/a\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003cb\u003eCheck other posts on Java Programming in this link\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-programming.html\"\u003ehttp://www.comrevo.com/2017/08/java-programming.html\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comrevo.com/feeds/1829550244252789390/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comrevo.com/2017/08/java-swing-mouselistener-example.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/1829550244252789390"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/1829550244252789390"},{"rel":"alternate","type":"text/html","href":"https://www.comrevo.com/2017/08/java-swing-mouselistener-example.html","title":"Java Swing Mouse Listener | MouseListener in Java Swing Example | MouseListener Interface in Java"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://i.ytimg.com/vi/M1BF8kFQV_0/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-1061554284969906655"},"published":{"$t":"2017-08-22T21:35:00.003+05:30"},"updated":{"$t":"2020-10-14T09:59:42.856+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"Java Swing Radio Button Example | Swing Button Group | Java Swing Radio Button Only One Selected"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see Java Swing Radio Button Example | Swing Button Group | Java Swing Radio Button Only One Selected.\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eWatch following video:\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\n  \n  \n  \u003ciframe width\u003d\"640\" height\u003d\"360\" src\u003d\"https://www.youtube.com/embed/0p9d_PXCaWE\" frameborder\u003d\"0\" allow\u003d\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\u003c/iframe\u003e\n  \n  \n  \u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eWatch on YouTube:\u0026nbsp;\u003ca href\u003d\"https://www.youtube.com/watch?v\u003d0p9d_PXCaWE\" target\u003d\"_blank\"\u003ehttps://www.youtube.com/watch?v\u003d0p9d_PXCaWE\u003c/a\u003e\u003c/b\u003e\u0026nbsp;\u003c/span\u003e\u003c/div\u003e\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003ca name\u003d'more'\u003e\u003c/a\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003eTo know\u0026nbsp;\u003cb\u003ewhat is Swing, how Swing is different from Applet, how to create Swing Application\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/swing-in-java-with-example.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/swing-in-java-with-example.html\u003c/a\u003e\u003cb\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/b\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To know\u0026nbsp;\u003cb\u003ehow to generate event in Java Swing along with Java Swing program for addition of two numbers\u003c/b\u003e; check this post\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\" target\u003d\"_blank\"\u003ehttp://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html\u003c/a\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Here, we will see Java Swing program for adding radio buttons on frame.\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In Swing, we can add radio buttons on frame by creating object of\u0026nbsp;\u003cb\u003eJRadioButton\u003c/b\u003e\u0026nbsp;and by calling add() method.\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; The difference between checkboxes and radio buttons is that we can select multiple checkboxes while we can select only one radio button. To make such change in our program, we need to create a group of radio button out of which only one radio button can be selected. We can create group of radio button by creating object of class ButtonGroup and we need to call add() method.\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Go through the following program:\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cb style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003eSwingRadio.java\u0026nbsp;\u003c/span\u003e\u003c/b\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport javax.swing.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eimport java.awt.event.*;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003epublic class SwingRadio\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;public static void main(String args[])\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Abc obj\u003dnew Abc();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eclass Abc extends JFrame implements ActionListener\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; JLabel l1,l2,l3,l4;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; JTextField t1,t2;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; JButton b;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; JRadioButton r1,r2,r3;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; public Abc()\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;{\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setLayout(new FlowLayout());\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l1\u003dnew JLabel(\"Name:\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;t1\u003dnew JTextField(25);\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l2\u003dnew JLabel(\"College:\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;t2\u003dnew JTextField(25);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l3\u003dnew JLabel(\"Department:\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;r1\u003dnew JRadioButton(\"Computer Department\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;r2\u003dnew JRadioButton(\"Electronics Department\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;r3\u003dnew JRadioButton(\"IT Department\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;ButtonGroup bg\u003dnew ButtonGroup();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;bg.add(r1);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;bg.add(r2);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;bg.add(r3);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;b\u003dnew JButton(\"Submit\");\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;l4\u003dnew JLabel();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l1);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t1);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l2);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t2);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l3);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(r1);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(r2);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(r3);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(b);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l4);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;b.addActionListener(this);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setVisible(true);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setSize(350,400);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;public void actionPerformed(ActionEvent ae)\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; {\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; String name\u003dt1.getText();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; String college\u003dt2.getText();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; String message;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; if(r1.isSelected())\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;message\u003d\"Welcome \"+name+\" To \"+college+\", \"+r1.getText();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;l4.setText(message);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; if(r2.isSelected())\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;message\u003d\"Welcome \"+name+\" To \"+college+\",\"+r2.getText();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;l4.setText(message);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; if(r3.isSelected())\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;message\u003d\"Welcome \"+name+\" To \"+college+\",\"+r3.getText();\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;l4.setText(message);\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; }\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e}\u003c/span\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp;\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003cbr /\u003e\u003c/span\u003e\n\u003cbr /\u003e\n\u003cdiv dir\u003d\"ltr\" style\u003d\"orphans: auto; text-align: left; text-indent: 0px; widows: 1;\" trbidi\u003d\"on\"\u003e\n\u003cdiv style\u003d\"font-family: \u0026quot;times new roman\u0026quot;;\"\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eHow To Run:\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003ctable border\u003d\"1\"\u003e\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/prog$ javac SwingRadio.java\u0026nbsp;\u003c/span\u003e\u003cbr /\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003eparag@parag-Inspiron-N4010:~/Desktop/prog$ java SwingRadio\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv style\u003d\"margin: 0px;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cb\u003eOutput:\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://3.bp.blogspot.com/-ItPd7Lu5wIg/WZwpxvGIKZI/AAAAAAAADnc/iaQgwl0iVEgrZjAZYWj_xaVApdX-ffGHwCLcBGAs/s1600/SwingCalculator1.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://4.bp.blogspot.com/-D1c-XUaqAog/WZxMHXdv1cI/AAAAAAAADnw/Q8hqf09toFIKjdyGDuFv2IeZwdLKyHwQgCLcBGAs/s1600/SwingCheckBox.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003ca href\u003d\"https://4.bp.blogspot.com/-lWXt6Sh7tBs/WZxWJ3UwhvI/AAAAAAAADoA/7iEudkxuO7oKf1DnUiI-mNSmsEuVDJBVwCLcBGAs/s1600/SwingRadio.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cimg border\u003d\"0\" data-original-height\u003d\"423\" data-original-width\u003d\"346\" src\u003d\"https://4.bp.blogspot.com/-lWXt6Sh7tBs/WZxWJ3UwhvI/AAAAAAAADoA/7iEudkxuO7oKf1DnUiI-mNSmsEuVDJBVwCLcBGAs/s1600/SwingRadio.jpeg\" /\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cbr /\u003e\n\u003cdiv class\u003d\"separator\" style\u003d\"clear: both; text-align: center;\"\u003e\n\u003ca href\u003d\"https://1.bp.blogspot.com/-urOIr8nor20/WZwp90oUFPI/AAAAAAAADng/gDy2OzxForQYagphKvMuqLFZK7_aDwxQwCLcBGAs/s1600/SwingCalculator2.jpeg\" style\u003d\"margin-left: 1em; margin-right: 1em;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003cb\u003eCheck other posts on Java Programming in this link\u0026nbsp;\u003ca href\u003d\"http://www.comrevo.com/2017/08/java-programming.html\"\u003ehttp://www.comrevo.com/2017/08/java-programming.html\u003c/a\u003e\u003c/b\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cbr /\u003e\n\u003cdiv\u003e\n\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cspan style\u003d\"font-size: large;\"\u003e\u003cbr /\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comrevo.com/feeds/1061554284969906655/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comrevo.com/2017/08/java-swing-radio-button-example.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/1061554284969906655"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/913600556879440043/posts/default/1061554284969906655"},{"rel":"alternate","type":"text/html","href":"https://www.comrevo.com/2017/08/java-swing-radio-button-example.html","title":"Java Swing Radio Button Example | Swing Button Group | Java Swing Radio Button Only One Selected"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"https://www.blogger.com/profile/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https://i.ytimg.com/vi/0p9d_PXCaWE/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}}]}});