{"id":41010,"date":"2016-09-30T15:00:13","date_gmt":"2016-09-30T12:00:13","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=41010"},"modified":"2016-09-28T11:05:11","modified_gmt":"2016-09-28T08:05:11","slug":"java-swingx-game-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/","title":{"rendered":"Java Swingx Game Example"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p>Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user interface (GUI) for Java programs. Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit (AWT). JAVA provides a rich set of libraries to create Graphical User Interface in platform independent way.<\/p>\n<p>Swing API is set of extensible GUI Components to ease developer\u2019s life to create JAVA based Front End\/ GUI Applications. It is build upon top of <code>AWT<\/code> API and acts as replacement of AWT API as it has almost every control corresponding to <code>AWT<\/code> controls. Swing component follows a Model-View-Controller architecture to fulfill the following criteria.<\/p>\n<ul>\n<li>A single API is to be sufficient to support multiple look and feel.<\/li>\n<li>API is to model driven so that highest level API is not required to have the data.<\/li>\n<li>API is to use the Java Bean model so that Builder Tools and IDE can provide better services to the developers to use it.<\/li>\n<\/ul>\n<h2>2. JAVA Swing<\/h2>\n<p>Unlike AWT, Java Swing provides platform-independent and lightweight components.\u00a0The javax.swing package provides classes for java swing API such as <code>JButton<\/code>, <code>JTextField<\/code>, <code>JTextArea<\/code>, <code>JRadioButton<\/code>, <code>JCheckbox<\/code>, <code>JMenu<\/code>, <code>JColorChooser<\/code> etc.<\/p>\n<h3>2.1 MVC Architecture<\/h3>\n<p>Swing API architecture follows loosely based MVC architecture in the following manner.<\/p>\n<ul>\n<li>A Model represents component\u2019s data.<\/li>\n<li>View represents visual representation of the component\u2019s data.<\/li>\n<li>Controller takes the input from the user on the view and reflects the changes in Component\u2019s data.<\/li>\n<li>Swing component have Model as a seperate element and View and Controller part are clubbed in User Interface elements. Using this way, Swing has pluggable look-and-feel architecture.<\/li>\n<\/ul>\n<p>Every user interface considers the following three main aspects:<\/p>\n<ul>\n<li><b>UI elements<\/b> : These are the core visual elements the user eventually sees and interacts with. GWT provides a huge list of widely used and common elements varying from basic to complex.<\/li>\n<li><b>Layouts<\/b>: They define how UI elements should be organized on the screen and provide a final look and feel to the GUI (Graphical User Interface).<\/li>\n<li><b>Behavior<\/b>: These are events which occur when the user interacts with UI elements.<\/li>\n<\/ul>\n<h3>2.2 Swing Features<\/h3>\n<ul>\n<li><b>Light Weight<\/b> \u2013 Swing component are independent of native Operating System\u2019s API as Swing API controls are rendered mostly using pure JAVA code instead of underlying operating system calls.<\/li>\n<li><b>Rich controls<\/b> \u2013 Swing provides a rich set of advanced controls like Tree, TabbedPane, slider, colorpicker, table controls.<\/li>\n<li><b>Highly Customizable<\/b> \u2013 Swing controls can be customized in very easy way as visual apperance is independent of internal representation.<\/li>\n<li><b>Pluggable look-and-feel<\/b>\u2013 SWING based GUI Application look and feel can be changed at run time based on available values.<\/li>\n<\/ul>\n<h3>2.3 Setup<\/h3>\n<p><b>Popular Java Editors<\/b>:<br \/>\nTo write your java programs you will need a text editor. There are even more sophisticated IDE available in the market. But for now, you can consider one of the following:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li>Notepad: On Windows machine you can use any simple text editor like Notepad TextPad.<\/li>\n<li>NetBeans: is a Java IDE that is open source and free which can be downloaded from <a href=\"http:\/\/www.netbeans.org\/index.html\">http:\/\/www.netbeans.org\/index.html<\/a>.<\/li>\n<li>Eclipse: is also a java IDE developed by the eclipse open source community and can be downloaded from http:\/\/www.eclipse.org<\/li>\n<\/ul>\n<p><b>Prerequisite<\/b><br \/>\nThis example is developed on Eclipse therefore a compatible Eclipse IDE is required to be installed on the system.<br \/>\nWe also need WindowBuilder tool to be installed on Eclipse IDE for the easiness of the work. To learn how to install WindowBuilder tool please visit the Setup section 2.1 of the following link <a href=\"https:\/\/examples.javacodegeeks.com\/desktop-java\/swing\/java-swing-form-example\/\"><strong>click here<\/strong><\/a>.<\/p>\n<h3>2.4 Class and description<\/h3>\n<ul>\n<li><b>Component<\/b>: A Component is the abstract base class for the non menu user-interface controls of SWING. Component represents an object with graphical representation.<\/li>\n<li><b>Container<\/b>: A Container is a component that can contain other SWING components.<\/li>\n<li><b>JComponent<\/b>: A JComponent is a base class for all swing UI components. In order to use a swing component that inherits from JComponent, component must be in a containment hierarchy whose root is a top-level Swing container.<\/li>\n<\/ul>\n<h3>2.5 SWING UI Elements<\/h3>\n<ul>\n<ul>\n<li><b>JLabel<\/b>: A JLabel object is a component for placing text in a container.<\/li>\n<li><b>JButton<\/b> This class creates a labeled button.<\/li>\n<li><b>JColorChooser<\/b> A JColorChooser provides a pane of controls designed to allow a user to manipulate and select a color.<\/li>\n<li><b>JCheck Box<\/b> A JCheckBox is a graphical component that can be in either an on (true) or off (false) state.<\/li>\n<li><b>JRadioButton<\/b> The JRadioButton class is a graphical component that can be in either an on (true) or off (false) state. in a group.<\/li>\n<li><b>JList<\/b> A JList component presents the user with a scrolling list of text items.<\/li>\n<li><b>JComboBox<\/b> A JComboBox component presents the user with a to show up menu of choices.<\/li>\n<li><b>JTextField<\/b> A JTextField object is a text component that allows for the editing of a single line of text.<\/li>\n<li><b>JPasswordField<\/b> A JPasswordField object is a text component specialized for password entry.<\/li>\n<li><b>JTextArea<\/b> A JTextArea object is a text component that allows for the editing of a multiple lines of text.<\/li>\n<li><b>ImageIcon<\/b> A ImageIcon control is an implementation of the Icon interface that paints Icons from Images.<\/li>\n<li><b> JScrollbar<\/b> A Scrollbar control represents a scroll bar component in order to enable user to select from range of values.<\/li>\n<li><b>JOptionPane<\/b> JOptionPane provides set of standard dialog boxes that prompt users for a value or informs them of something.<\/li>\n<\/ul>\n<\/ul>\n<h2>3. Creating Swing Game<\/h2>\n<p>We will learn Swing basics through this example i.e, JavaSwingExample.java<\/p>\n<p>Code for JavaSwingExample.java<\/p>\n<p><span style=\"text-decoration: underline;\"><em>SwingGameExample.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">import javax.swing.*;         \r\n\r\n\r\npublic class SwingGameExample implements Runnable{\r\n   \r\n   final int WIDTH = 1000;\r\n   final int HEIGHT = 700;\r\n   \r\n   JFrame frame;\r\n   Canvas canvas;\r\n   BufferStrategy bufferStrategy;\r\n   \r\n   public SwingGameExample(){\r\n      frame = new JFrame(\"Basic SwingGameExample\");\r\n      \r\n      JPanel panel = (JPanel) frame.getContentPane();\r\n      panel.setPreferredSize(new Dimension(WIDTH, HEIGHT));\r\n      panel.setLayout(null);\r\n      \r\n      canvas = new Canvas();\r\n      canvas.setBounds(0, 0, WIDTH, HEIGHT);\r\n      canvas.setIgnoreRepaint(true);\r\n      \r\n      panel.add(canvas);\r\n      \r\n      canvas.addMouseListener(new MouseControl());\r\n      \r\n      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n      frame.pack();\r\n      frame.setResizable(false);\r\n      frame.setVisible(true);\r\n      \r\n      canvas.createBufferStrategy(2);\r\n      bufferStrategy = canvas.getBufferStrategy();\r\n      \r\n      canvas.requestFocus();\r\n   }\r\n           \r\n \r\n<\/pre>\n<p>This is one of the simplest Swing Game application you can write. It doesn\u2019t do much, but the code demonstrates the basic code in every Swing program:<\/p>\n<p>1.Import the pertinent packages.<br \/>\n2.Set up a top-level container.<br \/>\n3.Display the container.<br \/>\n4.Be thread-safe.<\/p>\n<p>The first line imports the main Swing package:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>SwingGameExample.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">import javax.swing.*;\r\n<\/pre>\n<p>This is the only package that JavaSwingExample needs. However, most Swing programs also need to import two AWT packages:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>SwingGameExample.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">import java.awt.*; \r\nimport java.awt.event.*; \r\n<\/pre>\n<p>These packages are required because Swing components use the AWT infrastructure, including the AWT event model. The event model governs how a component reacts to events such as button clicks and mouse motion. You\u2019ll learn more about events in the upcoming section Handling Events (in the Creating a GUI with JFC\/Swing trail).<\/p>\n<p>Every program with a Swing GUI must has at least one top-level Swing container. A top-level Swing container provides the support Swing components need for painting and event handling. There are three commonly used top-level Swing containers: <code>JFrame<\/code>, <code>JDialog<\/code>, and (for applets) <code>JApplet<\/code>. Each <code>JFrame<\/code> object implements a single main window, and each <code>JDialog<\/code> implements a secondary window (a window dependent on another window). Each <code>JApplet<\/code> object implements an applet\u2019s display area within a browser window. (JApplet is covered in How to Make Applets(in the Creating a GUI with JFC\/Swing trail).)<\/p>\n<p>The JavaSwingExample example has only one top-level container, a <code>JFrame<\/code>. Imple\u00admented as an instance of the <code>JFrame<\/code> class, a frame is a window that, by default, has dec\u00adorations such as a border, a title, and buttons for iconifying and closing the window. Applications with a GUI typically use at least one frame.<\/p>\n<p>The Output of the code when executed will look like the one below.<\/p>\n<p><figure id=\"attachment_41012\" aria-describedby=\"caption-attachment-41012\" style=\"width: 857px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/09\/GameExample.jpg\"><img decoding=\"async\" class=\"size-full wp-image-41012\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/09\/GameExample.jpg\" alt=\"GameExample\" width=\"857\" height=\"701\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/09\/GameExample.jpg 857w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/09\/GameExample-300x245.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/09\/GameExample-768x628.jpg 768w\" sizes=\"(max-width: 857px) 100vw, 857px\" \/><\/a><figcaption id=\"caption-attachment-41012\" class=\"wp-caption-text\">GameExample<\/figcaption><\/figure><\/p>\n<h2>4. Download The Source Code<\/h2>\n<p>Here we have demonstrated how to develop a game using JAVA Swing.<\/p>\n<div class=\"download\"><strong><br \/>\n<\/strong>You can download the full source code of this example here<strong>:\u00a0<a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/09\/SwingGameExample.zip\">SwingGameExample<\/a><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user interface (GUI) for Java programs. Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit (AWT). JAVA provides a rich &hellip;<\/p>\n","protected":false},"author":98,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":["post-41010","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Swingx Game Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Swingx Game Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/jyoti.jha.9256\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-30T12:00:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jyoti Jha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jyoti Jha\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\"},\"author\":{\"name\":\"Jyoti Jha\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7\"},\"headline\":\"Java Swingx Game Example\",\"datePublished\":\"2016-09-30T12:00:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\"},\"wordCount\":1220,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"articleSection\":[\"swing\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\",\"name\":\"Java Swingx Game Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2016-09-30T12:00:13+00:00\",\"description\":\"1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Desktop Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"swing\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/swing\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Java Swingx Game Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7\",\"name\":\"Jyoti Jha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg\",\"caption\":\"Jyoti Jha\"},\"description\":\"Jyoti is a tech enthusiast and is an avid programmer. She holds a post graduation degree in (M.Tech) Computer Science Engineering from Thapar Univeristy, Patiala, India. Post her graduate studies, she has worked in Software companies such as SLK Software and Aricent, India as Software Engineer in various projects primarily in the field of Requirement analysis and design, implementing new algorithms in C++ and JAVA used in ISDN network and designing databases and. She is inquisitive about socio economic reforms as well as advancement in technical fronts and keep herself informed with TED talks and various blogs.\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\/\",\"https:\/\/www.facebook.com\/jyoti.jha.9256\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/jyoti-jha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Swingx Game Example - Java Code Geeks","description":"1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/","og_locale":"en_US","og_type":"article","og_title":"Java Swingx Game Example - Java Code Geeks","og_description":"1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/www.facebook.com\/jyoti.jha.9256","article_published_time":"2016-09-30T12:00:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Jyoti Jha","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jyoti Jha","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/"},"author":{"name":"Jyoti Jha","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7"},"headline":"Java Swingx Game Example","datePublished":"2016-09-30T12:00:13+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/"},"wordCount":1220,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","articleSection":["swing"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/","name":"Java Swingx Game Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2016-09-30T12:00:13+00:00","description":"1. Introduction Swing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/java-swingx-game-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Desktop Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/"},{"@type":"ListItem","position":4,"name":"swing","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/swing\/"},{"@type":"ListItem","position":5,"name":"Java Swingx Game Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7","name":"Jyoti Jha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg","caption":"Jyoti Jha"},"description":"Jyoti is a tech enthusiast and is an avid programmer. She holds a post graduation degree in (M.Tech) Computer Science Engineering from Thapar Univeristy, Patiala, India. Post her graduate studies, she has worked in Software companies such as SLK Software and Aricent, India as Software Engineer in various projects primarily in the field of Requirement analysis and design, implementing new algorithms in C++ and JAVA used in ISDN network and designing databases and. She is inquisitive about socio economic reforms as well as advancement in technical fronts and keep herself informed with TED talks and various blogs.","sameAs":["https:\/\/www.javacodegeeks.com\/","https:\/\/www.facebook.com\/jyoti.jha.9256"],"url":"https:\/\/examples.javacodegeeks.com\/author\/jyoti-jha\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/41010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/98"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=41010"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/41010\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=41010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=41010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=41010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}