{"id":10212,"date":"2015-08-25T07:00:34","date_gmt":"2015-08-25T11:00:34","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/?p=10212"},"modified":"2015-08-24T08:41:54","modified_gmt":"2015-08-24T12:41:54","slug":"multithreaded-graphics-and-double-buffering","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=10212","title":{"rendered":"Multithreaded Graphics and Double Buffering"},"content":{"rendered":"<p style=\"text-align: justify;\">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.<\/p>\n<p>&nbsp;<\/p>\n<pre>import java.applet.Applet;\r\nimport java.awt.*;\r\n\r\npublic class ShipSimulation extends Applet implements Runnable {\r\n\u00a0 ...\r\n\u00a0 \r\n\u00a0 public void run() {\r\n\u00a0\u00a0\u00a0 Ship s;\r\n\u00a0\u00a0\u00a0 for(int i=0; i\r\n\u00a0\u00a0 *\u00a0 When the \"stop\" button is pressed, stop the thread and\r\n\u00a0\u00a0 *\u00a0 clear the Vector of circles.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void actionPerformed(ActionEvent event) {\r\n\u00a0\u00a0\u00a0 if (event.getSource() == startButton) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (circles.size() == 0) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Erase any circles from previous run.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 getGraphics().clearRect(0, 0, getSize().width,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 getSize().height);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 animationThread = new Thread(this);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 animationThread.start();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int radius = 25;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int x = radius + randomInt(width - 2 * radius);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int y = radius + randomInt(height - 2 * radius);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int deltaX = 1 + randomInt(10);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int deltaY = 1 + randomInt(10);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 circles.addElement(new MovingCircle(x, y, radius, deltaX,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 deltaY));\r\n\u00a0\u00a0\u00a0 } else if (event.getSource() == stopButton) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (animationThread != null) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 animationThread = null;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 circles.removeAllElements();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 repaint();\r\n\u00a0 }\r\n\r\n\u00a0 \/** Each time around the loop, call paint and then take a\r\n\u00a0\u00a0 *\u00a0 short pause. The paint method will move the circles and\r\n\u00a0\u00a0 *\u00a0 draw them.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void run() {\r\n\u00a0\u00a0\u00a0 Thread myThread = Thread.currentThread();\r\n\u00a0\u00a0\u00a0 \/\/ Really while animationThread not null\r\n\u00a0\u00a0\u00a0 while(animationThread==myThread) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 repaint();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 pause(100);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 \/** Skip the usual screen-clearing step of update so that\r\n\u00a0\u00a0 *\u00a0 there is no flicker between each drawing step.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void update(Graphics g) {\r\n\u00a0\u00a0\u00a0 paint(g);\r\n\u00a0 }\r\n\r\n\u00a0 \/** Erase each circle's old position, move it, then draw it\r\n\u00a0\u00a0 *\u00a0 in new location.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void paint(Graphics g) {\r\n\u00a0\u00a0\u00a0 MovingCircle circle;\r\n\u00a0\u00a0\u00a0 for(int i=0; i windowWidth) &amp;&amp; (deltaX &gt; 0)) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 setDeltaX(-deltaX);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 if ((y -radius &lt; 0) &amp;&amp; (deltaY &lt; 0)) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 setDeltaY(-deltaY);\r\n\u00a0\u00a0\u00a0 } else if((y + radius &gt; windowHeight) &amp;&amp; (deltaY &gt; 0)) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 setDeltaY(-deltaY);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 public int getDeltaX() {\r\n\u00a0\u00a0\u00a0 return(deltaX);\r\n\u00a0 }\r\n\r\n\u00a0 public void setDeltaX(int deltaX) {\r\n\u00a0\u00a0\u00a0 this.deltaX = deltaX;\r\n\u00a0 }\r\n\r\n\u00a0 public int getDeltaY() {\r\n\u00a0\u00a0\u00a0 return(deltaY);\r\n\u00a0 }\r\n\r\n\u00a0 public void setDeltaY(int deltaY) {\r\n\u00a0\u00a0\u00a0 this.deltaY = deltaY;\r\n\u00a0 }\r\n}\r\n*\/\/\r\nSimpleCircle.java A class to store the x, y, and radius of a circle. Also, provides a draw method to paint the circle on the graphics object.\r\nimport java.awt.*;\r\n\r\n\/** A class to store an x, y, and radius, plus a draw method.\r\n\u00a0*\r\n\u00a0 *\/\r\n\r\npublic class SimpleCircle {\r\n\u00a0 private int x, y, radius;\r\n\r\n\u00a0 public SimpleCircle(int x, int y, int radius) {\r\n\u00a0\u00a0\u00a0 setX(x);\r\n\u00a0\u00a0\u00a0 setY(y);\r\n\u00a0\u00a0\u00a0 setRadius(radius);\r\n\u00a0 }\r\n\r\n\u00a0 \/** Given a Graphics, draw the SimpleCircle\r\n\u00a0\u00a0 *\u00a0 centered around its current position.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void draw(Graphics g) {\r\n\u00a0\u00a0\u00a0 g.fillOval(x - radius, y - radius,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 radius * 2, radius * 2);\r\n\u00a0 }\r\n\r\n\u00a0 public int getX() { return(x); }\r\n\r\n\u00a0 public void setX(int x) { this.x = x; }\r\n\r\n\u00a0 public int getY() { return(y); }\r\n\r\n\u00a0 public void setY(int y) { this.y = y; }\r\n\r\n\u00a0 public int getRadius() { return(radius); }\r\n\r\n\u00a0 public void setRadius(int radius) {\r\n\u00a0\u00a0\u00a0 this.radius = radius;\r\n\u00a0 }\r\n}\r\n*\/\/\r\nDoubleBufferBounce.java\u00a0 An enhancement to the previous applet containing bouncing circles. In this case, double buffering is used to improve the animation; all incremental updating is done in an off-screen image and then the image is drawn to the screen.\r\nimport java.applet.Applet;\r\nimport java.awt.*;\r\nimport java.awt.event.*;\r\nimport java.util.Vector;\r\n\r\n\/** Bounce circles around on the screen, using double buffering\r\n\u00a0*\u00a0 for speed and to avoid problems with overlapping circles.\r\n\u00a0*\u00a0 Overrides update to avoid flicker problems.\r\n\u00a0*\r\n\u00a0 *\/\r\n\r\npublic class DoubleBufferBounce extends Applet implements\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Runnable, ActionListener {\r\n\u00a0 private Vector circles;\r\n\u00a0 private int width, height;\r\n\u00a0 private Image offScreenImage;\r\n\u00a0 private Graphics offScreenGraphics;\r\n\u00a0 private Button startButton, stopButton;\r\n\u00a0 private Thread animationThread = null;\r\n\r\n\u00a0 public void init() {\r\n\u00a0\u00a0\u00a0 setBackground(Color.white);\r\n\u00a0\u00a0\u00a0 width = getSize().width;\r\n\u00a0\u00a0\u00a0 height = getSize().height;\r\n\u00a0\u00a0\u00a0 offScreenImage = createImage(width, height);\r\n\u00a0\u00a0\u00a0 offScreenGraphics = offScreenImage.getGraphics();\r\n\u00a0\u00a0\u00a0 \/\/ Automatic in some systems, not in others.\r\n\u00a0\u00a0\u00a0 offScreenGraphics.setColor(Color.black);\r\n\u00a0\u00a0\u00a0 circles = new Vector();\r\n\u00a0\u00a0\u00a0 startButton = new Button(\"Start a circle\");\r\n\u00a0\u00a0\u00a0 startButton.addActionListener(this);\r\n\u00a0\u00a0\u00a0 add(startButton);\r\n\u00a0\u00a0\u00a0 stopButton = new Button(\"Stop all circles\");\r\n\u00a0\u00a0\u00a0 stopButton.addActionListener(this);\r\n\u00a0\u00a0\u00a0 add(stopButton);\r\n\u00a0 }\r\n\r\n\u00a0 \/** When the \"start\" button is pressed, start the animation\r\n\u00a0\u00a0 *\u00a0 thread if it is not already started. Either way, add a\r\n\u00a0\u00a0 *\u00a0 circle to the Vector of circles that are being bounced.\r\n\u00a0\u00a0 * \u00a0\r\n\r\n\r\n\u00a0\u00a0 *\u00a0 When the \"stop\" button is pressed, stop the thread and\r\n\u00a0\u00a0 *\u00a0 clear the Vector of circles.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void actionPerformed(ActionEvent event) {\r\n\u00a0\u00a0\u00a0 if (event.getSource() == startButton) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (circles.size() == 0) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 animationThread = new Thread(this);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 animationThread.start();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int radius = 25;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int x = radius + randomInt(width - 2 * radius);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int y = radius + randomInt(height - 2 * radius);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int deltaX = 1 + randomInt(10);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int deltaY = 1 + randomInt(10);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 circles.addElement(new MovingCircle(x, y, radius, deltaX,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 deltaY));\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 repaint();\r\n\u00a0\u00a0\u00a0 } else if (event.getSource() == stopButton) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (animationThread != null) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 animationThread = null;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 circles.removeAllElements();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 \/** Each time around the loop, move each circle based on its\r\n\u00a0\u00a0 *\u00a0 current position and deltaX\/deltaY values. These values\r\n\u00a0\u00a0 *\u00a0 reverse when the circles reach the edge of the window.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public void run() {\r\n\u00a0\u00a0\u00a0 MovingCircle circle;\r\n\u00a0\u00a0\u00a0 Thread myThread = Thread.currentThread();\r\n\u00a0\u00a0\u00a0 \/\/ Really while animationThread not null.\r\n\u00a0\u00a0\u00a0 while(animationThread==myThread) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 for(int j=0; j= NUMIMAGES) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 index = 0;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 parent.repaint();\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 try {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Thread.sleep(100);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 } catch (InterruptedException e) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;\u00a0\u00a0 \/\/ Break while loop.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n}\r\n*\/\/\r\nTimedAnimation.java An applet that demonstrates animation of an image by using a Timer. Note that Timer is located in the javax.swing package.\r\nimport java.awt.*;\r\nimport javax.swing.*;\r\n\r\n\/** An example of performing animation through Swing timers.\r\n\u00a0*\u00a0 Two timed Dukes are created with different timer periods.\r\n\u00a0*\r\n\u00a0 *\/\r\n\r\npublic class TimedAnimation extends JApplet {\r\n\u00a0 private static final int NUMDUKES = 2;\r\n\u00a0 private TimedDuke[] dukes;\r\n\u00a0 private int i, index;\r\n\r\n\u00a0 public void init() {\r\n\u00a0\u00a0\u00a0 dukes = new TimedDuke[NUMDUKES];\r\n\u00a0\u00a0\u00a0 setBackground(Color.white);\r\n\u00a0\u00a0\u00a0 dukes[0] = new TimedDuke( 1, 100, this);\r\n\u00a0\u00a0\u00a0 dukes[1] = new TimedDuke(-1, 500, this);\r\n\r\n\u00a0 }\r\n\r\n\u00a0 \/\/\u00a0 Start each Duke timer.\r\n\r\n\u00a0 public void start() {\r\n\u00a0\u00a0\u00a0 for (int i=0; i= NUMIMAGES) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 index = 0;\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 parent.repaint();\r\n\u00a0 }\r\n\r\n\u00a0 \/\/ Public service to start the timer.\r\n\u00a0 public void startTimer() {\r\n\u00a0\u00a0\u00a0 timer.start();\r\n\u00a0 }\r\n\r\n\u00a0 \/\/ Public service to stop the timer.\r\n\u00a0 public void stopTimer() {\r\n\u00a0\u00a0\u00a0 timer.stop();\r\n\u00a0 }\r\n}\r\n**\/\/<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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. &nbsp; import java.applet.Applet; import java.awt.*; public class ShipSimulation extends Applet implements Runnable { \u00a0 &#8230; \u00a0 \u00a0 public void run() { \u00a0\u00a0\u00a0 Ship s; \u00a0\u00a0\u00a0 &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=10212\">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-10212","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":26860,"url":"http:\/\/bangla.sitestree.com\/?p=26860","url_meta":{"origin":10212,"position":0},"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":[]},{"id":10329,"url":"http:\/\/bangla.sitestree.com\/?p=10329","url_meta":{"origin":10212,"position":1},"title":"Position circles down the diagonal so that their borders","author":"","date":"August 26, 2015","format":false,"excerpt":"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\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":10279,"url":"http:\/\/bangla.sitestree.com\/?p=10279","url_meta":{"origin":10212,"position":2},"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":10308,"url":"http:\/\/bangla.sitestree.com\/?p=10308","url_meta":{"origin":10212,"position":3},"title":"Message.java Applet that reads customization parameters from an HTML file","author":"","date":"August 26, 2015","format":false,"excerpt":"******************* Message.java Applet that reads customization parameters from an HTML file ******************* import java.applet.Applet; import java.awt.*; **************** \u00a0 public class Message extends Applet { \u00a0 private int fontSize; \u00a0 private String message; \u00a0 \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.black); \u00a0\u00a0\u00a0 setForeground(Color.white); \u00a0\u00a0 \u00a0 \u00a0\u00a0\u00a0 \/\/ Base font size on\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":26996,"url":"http:\/\/bangla.sitestree.com\/?p=26996","url_meta":{"origin":10212,"position":4},"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":10204,"url":"http:\/\/bangla.sitestree.com\/?p=10204","url_meta":{"origin":10212,"position":5},"title":"ThreadedEchoServer.java A multithreaded version of EchoServer, where each client request is serviced on a separate thread. Requires the following classes","author":"","date":"August 25, 2015","format":false,"excerpt":"import java.net.*; import java.io.*; \/** A multithreaded variation of EchoServer. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown; \u00a0*\u00a0 may be freely used or adapted. \u00a0*\/ public class ThreadedEchoServer extends EchoServer \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 implements\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":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10212","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=10212"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10212\/revisions"}],"predecessor-version":[{"id":10213,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10212\/revisions\/10213"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10212"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}