<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ankit Virparia &#187; Method communication</title>
	<atom:link href="http://ankit.co/tag/method-communication/feed" rel="self" type="application/rss+xml" />
	<link>http://ankit.co</link>
	<description>A Programmer, Designer and Trainer</description>
	<lastBuildDate>Sun, 11 May 2014 04:15:47 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>Rotating Colorful Squares</title>
		<link>http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-squares?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rotating-colorful-squares</link>
		<comments>http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-squares#comments</comments>
		<pubDate>Sun, 06 Jan 2013 05:15:42 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Applet]]></category>
		<category><![CDATA[Method communication]]></category>
		<category><![CDATA[Multithreading]]></category>
		<category><![CDATA[Thread + Applet]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=191</guid>
		<description><![CDATA[<p>Definition: Write an applet that draws four squares of equal size &#038; of different colors such that they cover up the whole applet area. The applet should operate correctly even if it is resized. Output:</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-squares">Rotating Colorful Squares</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h3>Definition:</h3>
<p> Write an applet that draws four squares of equal size &#038; of different colors such that they cover up the whole applet area. The applet should operate correctly even if it is resized.</p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class rotateSquares extends Applet implements Runnable
{
	Color[] clr = {Color.red, Color.green, Color.pink, Color.blue};
	int cnt = 0;
	Thread t;
	public void init()
	{
		t = new Thread(this);
		t.start();
		setBackground(Color.black);	
	}
	
	public void run()
	{
		try
		{
			while(true)
			{
				
				repaint();
				t.sleep(1000);
				cnt++;	
				if(cnt&gt;3){cnt=0;}
			}
		}
		catch(Exception e)
		{
			System.out.println(e);	
		}
	}
		
	public void paint(Graphics g)
	{
		int w = getWidth();
		int h = getHeight();
		
		int tmp = cnt;
		for(int i=0;i&lt;4;i++)
		{
		 g.setColor(clr[tmp++]);
		 if(tmp&gt;3)tmp=0;
		 
		 if(i==0) g.fillRect(0,0,w/2,h/2);
		 else if(i==1) g.fillRect(w/2,0,w/2,h/2);
		 else if(i==2) g.fillRect(w/2,h/2,w/2,h/2);
		 else if(i==3) g.fillRect(0,h/2,w/2,h/2); 
		}
	}	
	
}

/*
&lt;applet code=&quot;rotateSquares&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><strong>Output:</strong><img src="http://ankit.co/wp-content/uploads/2013/01/p4.jpg" alt="p4" width="500" height="500" class="aligncenter size-full wp-image-3539" /></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-squares">Rotating Colorful Squares</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-squares/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rotating Colorful Disk</title>
		<link>http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-disk?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rotating-colorful-disk</link>
		<comments>http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-disk#comments</comments>
		<pubDate>Sun, 06 Jan 2013 04:57:24 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Applet]]></category>
		<category><![CDATA[Method communication]]></category>
		<category><![CDATA[Multithreading]]></category>
		<category><![CDATA[Thread + Applet]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=189</guid>
		<description><![CDATA[<p>Once again, One more tutorial on Method communication. But here we need communication between Applet Life cycle methods and Thread-> run() method. To draw a disc, We have used 4 Arcs of 90 degrees each. For display color rotation, We have used Color[]. Rest everything is self explanatory. You may leave a comment in case [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-disk">Rotating Colorful Disk</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Once again, One more tutorial on Method communication. But here we need communication between Applet Life cycle methods and Thread-> run() method. To draw a disc, We have used 4 Arcs of 90 degrees each. For display color rotation, We have used Color[]. Rest everything is self explanatory. You may leave a comment in case you face any difficulty.</p>
<p><strong>File Name:</strong> rotateArc.java</p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class rotateArc extends Applet implements Runnable
{
	Color[] clr = {Color.red, Color.green, Color.pink, Color.blue};
	int cnt = 0;
	Thread t;
	public void init()
	{
		t = new Thread(this);
		t.start();
		setBackground(Color.black);	
	}
	
	public void run()
	{
		try
		{
			while(true)
			{
				
				repaint();
				t.sleep(1000);
				cnt++;	
				if(cnt&gt;3){cnt=0;}
			}
		}
		catch(Exception e)
		{
			System.out.println(e);	
		}
	}
		
	public void paint(Graphics g)
	{
		int tmp = cnt;
		for(int i=0;i&lt;4;i++)
		{
		 g.setColor(clr[tmp++]);
		 if(tmp&gt;3)tmp=0;
		 g.fillArc(0,0,500,500,90*i,90);
		}
	}	
	
}

/*
&lt;applet code=&quot;rotateArc&quot; width=&quot;500&quot; height=&quot;500&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><img src="http://ankit.co/wp-content/uploads/2013/01/p3.jpg" alt="p3" width="500" height="500" class="aligncenter size-full wp-image-3536" /></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-disk">Rotating Colorful Disk</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/applet/rotating-colorful-disk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cartoon Character &#8211; Moving Hands</title>
		<link>http://ankit.co/tutorials/java-tutorials/applet/cartoon-character-moving-hands?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cartoon-character-moving-hands</link>
		<comments>http://ankit.co/tutorials/java-tutorials/applet/cartoon-character-moving-hands#comments</comments>
		<pubDate>Sun, 06 Jan 2013 04:29:28 +0000</pubDate>
		<dc:creator><![CDATA[Ankit Virparia]]></dc:creator>
				<category><![CDATA[Applet]]></category>
		<category><![CDATA[cartoon]]></category>
		<category><![CDATA[Method communication]]></category>

		<guid isPermaLink="false">http://ankit.co/?p=184</guid>
		<description><![CDATA[<p>Our aim of this tutorial is to learn the communication between applet life cycle methods. What I mean by communication is: One of the method may generate some values which is used by other method/methods. Here we want a scenario that when user changes the Browser tab or minimize-maximize the appletviewer, Position of the hands(of [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/applet/cartoon-character-moving-hands">Cartoon Character &#8211; Moving Hands</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Our aim of this tutorial is to learn the communication between applet life cycle methods. What I mean by communication is: One of the method may generate some values which is used by other method/methods. Here we want a scenario that when user changes the Browser tab or minimize-maximize the appletviewer, Position of the hands(of cartoon character!) should be toggled. And this will create an view like a cartoon character is doing exercise.</p>
<pre class="brush: java; title: ; notranslate">
import java.applet.*;
import java.awt.*;

public class toonApplet extends Applet
{
	int y = 200;
	public void init()
	{	
		setBackground(Color.YELLOW);
	}
	
	public void stop()	
	{
		if(y==200)y = 50;
		else y = 200;
	}
	
	public void paint(Graphics g)
	{
		g.drawOval(200,50,100,100);
		g.drawRect(50,150,400,50);

		g.drawRect(50,y,50,100);
		g.drawRect(400,y,50,100);

		g.drawRect(150,200,200,300);

		g.drawRect(150,500,50,100);
		g.drawRect(300,500,50,100);
	}
}
/*
&lt;applet code=&quot;toonApplet&quot; width=&quot;500&quot; height=&quot;700&quot;&gt;&lt;/applet&gt;
*/
</pre>
<p><img src="http://ankit.co/wp-content/uploads/2013/01/p2.jpg" alt="p2" width="437" height="518" class="aligncenter size-full wp-image-3533" /></p>
<p>The post <a rel="nofollow" href="http://ankit.co/tutorials/java-tutorials/applet/cartoon-character-moving-hands">Cartoon Character &#8211; Moving Hands</a> appeared first on <a rel="nofollow" href="http://ankit.co">Ankit Virparia</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankit.co/tutorials/java-tutorials/applet/cartoon-character-moving-hands/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
