{"id":10329,"date":"2015-08-26T07:30:17","date_gmt":"2015-08-26T11:30:17","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/?p=10329"},"modified":"2016-09-26T18:08:32","modified_gmt":"2016-09-26T22:08:32","slug":"position-circles-down-the-diagonal-so-that-their-borders","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=10329","title":{"rendered":"Position circles down the diagonal so that their borders"},"content":{"rendered":"<pre>import java.awt.*;\r\nimport java.applet.Applet;\r\n\r\n\/** Position circles down the diagonal so that their borders\r\n\u00a0*\u00a0 just touch. Illustrates that AWT components are \r\n\u00a0*\u00a0 rectangular and opaque.\r\n\u00a0 *\/\r\n\r\npublic class CircleTest2 extends Applet {\r\n\u00a0 public void init() {\r\n\u00a0\u00a0\u00a0 setBackground(Color.lightGray);\r\n\u00a0\u00a0\u00a0 setLayout(null); \/\/ Turn off layout manager.\r\n\u00a0\u00a0\u00a0 Circle circle;\r\n\u00a0\u00a0\u00a0 int radius = getSize().width\/6;\r\n\u00a0\u00a0\u00a0 int deltaX = round(2.0 * (double)radius \/ Math.sqrt(2.0));\r\n\u00a0\u00a0\u00a0 for (int x=radius; x&lt;6*radius; x=x+deltaX) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 circle = new Circle(Color.black, radius);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 add(circle);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 circle.setCenter(x, x);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 private int round(double num) {\r\n\u00a0\u00a0\u00a0 return((int)Math.round(num));\r\n\u00a0 }\r\n}\r\n*********************************\r\nCircle.java\r\n*********************************\r\nimport java.awt.*;\r\n\r\n\/** A Circle component built using a Canvas. \r\n\u00a0*\r\n\u00a0 *\/\r\n\r\npublic class Circle extends Canvas {\r\n\u00a0 private int width, height;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\n\u00a0 public Circle(Color foreground, int radius) {\r\n\u00a0\u00a0\u00a0 setForeground(foreground);\r\n\u00a0\u00a0\u00a0 width = 2*radius;\r\n\u00a0\u00a0\u00a0 height = 2*radius;\r\n\u00a0\u00a0\u00a0 setSize(width, height);\r\n\u00a0 }\r\n\r\n\u00a0 public void paint(Graphics g) {\r\n\u00a0\u00a0\u00a0 g.fillOval(0, 0, width, height);\r\n\u00a0 }\r\n\r\n\u00a0 public void setCenter(int x, int y) {\r\n\u00a0\u00a0\u00a0 setLocation(x - width\/2, y - height\/2);\r\n\u00a0 }\r\n}\r\n*****************************<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders \u00a0*\u00a0 just touch. Illustrates that AWT components are \u00a0*\u00a0 rectangular and opaque. \u00a0 *\/ public class CircleTest2 extends Applet { \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.lightGray); \u00a0\u00a0\u00a0 setLayout(null); \/\/ Turn off layout manager. \u00a0\u00a0\u00a0 Circle circle; \u00a0\u00a0\u00a0 int radius = &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=10329\">Continue reading<\/a><\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1417,1424],"tags":[706,308,285],"class_list":["post-10329","post","type-post","status-publish","format-standard","hentry","category-code-programming-samples--","category-javaj2eej2me","tag-code","tag-java","tag-285","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":26996,"url":"http:\/\/bangla.sitestree.com\/?p=26996","url_meta":{"origin":10329,"position":0},"title":"Position circles down the diagonal so that their borders #Programming Code Examples #Java\/J2EE\/J2ME #AWT Components","author":"Author-Check- Article-or-Video","date":"May 7, 2021","format":false,"excerpt":"import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders * just touch. Illustrates that AWT components are * rectangular and opaque. *\/ public class CircleTest2 extends Applet { public void init() { setBackground(Color.lightGray); setLayout(null); \/\/ Turn off layout manager. Circle circle; int radius = getSize().width\/6;\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10279,"url":"http:\/\/bangla.sitestree.com\/?p=10279","url_meta":{"origin":10329,"position":1},"title":"BetterCircleTest.java","author":"","date":"August 26, 2015","format":false,"excerpt":"********************** BetterCircleTest.java ********************** import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders \u00a0*\u00a0 just touch. Illustrates that Java 1.1 lightweight \u00a0*\u00a0 components can be partially transparent. \u00a0* \u00a0 *\/ public class BetterCircleTest extends Applet { \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.lightGray); \u00a0\u00a0\u00a0 setLayout(null); \u00a0\u00a0\u00a0\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27215,"url":"http:\/\/bangla.sitestree.com\/?p=27215","url_meta":{"origin":10329,"position":2},"title":"BetterCircleTest.java #Programming Code Examples #Java\/J2EE\/J2ME #Advanced Swing","author":"Author-Check- Article-or-Video","date":"May 14, 2021","format":false,"excerpt":"********************** BetterCircleTest.java ********************** import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders * just touch. Illustrates that Java 1.1 lightweight * components can be partially transparent. * *\/ public class BetterCircleTest extends Applet { public void init() { setBackground(Color.lightGray); setLayout(null); BetterCircle circle; int radius =\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10212,"url":"http:\/\/bangla.sitestree.com\/?p=10212","url_meta":{"origin":10329,"position":3},"title":"Multithreaded Graphics and Double Buffering","author":"","date":"August 25, 2015","format":false,"excerpt":"ShipSimulation.java\u00a0 Illustrates the basic approach of multithreaded graphics whereas a thread adjusts parameters affecting the appearance of the graphics and then calls repaint to schedule an update of the display. \u00a0 import java.applet.Applet; import java.awt.*; public class ShipSimulation extends Applet implements Runnable { \u00a0 ... \u00a0 \u00a0 public void run()\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26890,"url":"http:\/\/bangla.sitestree.com\/?p=26890","url_meta":{"origin":10329,"position":4},"title":"LineStyles.java Provides examples of the available styles for joining line segments #Programming Code Examples #Java\/J2EE\/J2ME #Drawing","author":"Author-Check- Article-or-Video","date":"May 4, 2021","format":false,"excerpt":"import javax.swing.*; import java.awt.*; import java.awt.geom.*; \/** A demonstration of different controls when joining two line * segments. The style of the line end point is controlled * through the capStyle parameter. * ************************************ public class LineStyles extends JPanel { private GeneralPath path; private static int x = 30, deltaX\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26860,"url":"http:\/\/bangla.sitestree.com\/?p=26860","url_meta":{"origin":10329,"position":5},"title":"Multithreaded Graphics and Double Buffering #Programming Code Examples #Java\/J2EE\/J2ME #Java Threads","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"ShipSimulation.java Illustrates the basic approach of multithreaded graphics whereas a thread adjusts parameters affecting the appearance of the graphics and then calls repaint to schedule an update of the display. import java.applet.Applet; import java.awt.*; public class ShipSimulation extends Applet implements Runnable { ... public void run() { Ship s; for(int\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/130"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10329"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10329\/revisions"}],"predecessor-version":[{"id":10330,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10329\/revisions\/10330"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10329"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}