<?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>Haiders WebSpace</title>
	<atom:link href="http://blog.creativeitp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.creativeitp.com</link>
	<description>Let&#039;s talk about IT</description>
	<lastBuildDate>Fri, 18 Nov 2011 17:36:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>TrueCrypt: A tool to encrypt volumes on-the-fly</title>
		<link>http://blog.creativeitp.com/posts-and-articles/cryptography/truecrypt-a-windowslinux-tool-to-encrypt-volumes-on-the-fly/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/cryptography/truecrypt-a-windowslinux-tool-to-encrypt-volumes-on-the-fly/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 00:55:03 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=578</guid>
		<description><![CDATA[TrueCrypt is a powerful yet free Open-Source disk encryption Software. I am quite satisfied with the software that I decided to introduce it here in my blog, may all future releases remain free to use! With TrueCrypt you can maintain an on-the-fly-encrypted volume (data storage device). On their website they explain &#8216;On-the-fly encryption&#8217; as an [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_579" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.creativeitp.com/wp-content/uploads/2011/11/TrueCrypt.jpg"><img src="http://blog.creativeitp.com/wp-content/uploads/2011/11/TrueCrypt-300x220.jpg" alt="" title="TrueCrypt" width="300" height="220" class="size-medium wp-image-579" /></a><p class="wp-caption-text">TrueCrypt</p></div>
<p><a href="http://www.truecrypt.org" title="TrueCrypt website" target="_blank">TrueCrypt</a> is a powerful yet free Open-Source disk encryption Software. I am quite satisfied with the software that I decided to introduce it here in my blog, may all future releases remain free to use!</p>
<p>With TrueCrypt you can maintain an on-the-fly-encrypted volume (data storage device). On their website they explain &#8216;On-the-fly encryption&#8217; as an automatic continuing encryption process to data right before it is saved and decrypted right after it is loaded. In simple words, you will end up having an encrypted volume to secure all your sensitive data inside. This volume can be mounted and accesses like any regular folder in your system each time you provide the right password and then dismounted to prevent access.</p>
<p>What I personally think makes this software special is the ease of using encrypted files right from the secured volume to the computer&#8217;s RAM. As such, if you have a video file, you will not wait until it is fully decrypted to play it, instead the stream will be decrypted right into the RAM while playing, the performance and speed is quite similar to playing any regular video file you have on your system. Brilliant, isn&#8217;t it?<br />
<span id="more-578"></span><br />
Similarly, files can be copied to and from a mounted TrueCrypt volume just like they are copied to/from any normal disk (drag-and-drop). Files are automatically being decrypted on the fly (in memory/RAM) while they are being read or copied from an encrypted TrueCrypt volume. </p>
<p>TrueCrypt &#8216;never saves any decrypted data to a disk – it only stores them temporarily in RAM (memory)&#8217;. In addition, it supports &#8216;hidden volumes&#8217;, which means that you may easily hide an encrypted volume inside an another encrypted volume without showing any evidence of its existence to other users of the system. This is a very important feature in case someone forces you to decrypt your sensitive data. (check TrueCrypt documentation for more information about hidden volumes).</p>
<p>To install and use in Linux, download the appropriate package from their website: <a href="http://www.truecrypt.org" title="TrueCrypt website" target="_blank">www.truecrypt.org</a>. </p>
<p>Since windows installation is wizard-based, I will leave that and cover the Linux installation procedure. First, download the Console-only version, in my case the file is called: <b>truecrypt-7.1-linux-console-x86.tar.gz</b> and was downloaded from the internet to: <strong>/home/haider/Downloads</strong>. Lets move it to the <b>/usr/local/bin</b> directory</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>haider<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>truecrypt-<span style="color: #000000;">7.1</span>-linux-console-x86.tar.gz <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p>Then navigate to where it was moved and extract the file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #c20cb9; font-weight: bold;">tar</span> xfzv truecrypt-<span style="color: #000000;">7.1</span>-linux-console-x86.tar.gz</pre></div></div>

<p>This should produce the bin file to be excuted: <strong>truecrypt-7.1-setup-console-x86</strong>. Good! lets now delete the archive file since we do not need it any more.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">rm</span> truecrypt-<span style="color: #000000;">7.1</span>-linux-console-x86.tar.gz</pre></div></div>

<p>Now, change the file&#8217;s permissions to 755</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> truecrypt-<span style="color: #000000;">7.1</span>-setup-console-x86</pre></div></div>

<p>Install using the following command and accept the terms of use (select option 1 to install)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>truecrypt-<span style="color: #000000;">7.1</span>-setup-console-x86</pre></div></div>

<p>After a successful installation, you may display all the software&#8217;s arguments and options with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">truecrypt <span style="color: #660033;">-help</span></pre></div></div>

<p>Further, lets create an encrypted volume. To do that use <strong>truecrypt -c</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">truecrypt <span style="color: #660033;">-c</span></pre></div></div>

<p>Check out the following example from my Linux box:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Volume <span style="color: #7a0874; font-weight: bold;">type</span>:
 <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Normal
 <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Hidden
Select <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000;">1</span>
&nbsp;
Enter volume path: <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>my-crypt
&nbsp;
Enter volume <span style="color: #c20cb9; font-weight: bold;">size</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>sizeK<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">size</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>M<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>sizeG<span style="color: #7a0874; font-weight: bold;">&#41;</span>: 500m
&nbsp;
Encryption algorithm:
 <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> AES
 <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Serpent
 <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Twofish
 <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> AES-Twofish
 <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> AES-Twofish-Serpent
 <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Serpent-AES
 <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Serpent-Twofish-AES
 <span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Twofish-Serpent
Select <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000;">1</span>
&nbsp;
Hash algorithm:
 <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> RIPEMD-<span style="color: #000000;">160</span>
 <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> SHA-<span style="color: #000000;">512</span>
 <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Whirlpool
Select <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000;">2</span>
&nbsp;
Filesystem:
 <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> None
 <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> FAT
 <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Linux Ext2
 <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Linux Ext3
 <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> Linux Ext4
Select <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: <span style="color: #000000;">5</span>
&nbsp;
Enter password: 
WARNING: Short passwords are easy to crack using brute force techniques<span style="color: #000000; font-weight: bold;">!</span>
&nbsp;
We recommend choosing a password consisting of <span style="color: #c20cb9; font-weight: bold;">more</span> than <span style="color: #000000;">20</span> characters. Are you sure you want to use a short password? <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">y</span>=Yes<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">n</span>=No<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>No<span style="color: #7a0874; font-weight: bold;">&#93;</span>: y
&nbsp;
Re-enter password: 
&nbsp;
Enter keyfile path <span style="color: #7a0874; font-weight: bold;">&#91;</span>none<span style="color: #7a0874; font-weight: bold;">&#93;</span>: 
&nbsp;
Please <span style="color: #7a0874; font-weight: bold;">type</span> at least <span style="color: #000000;">320</span> randomly chosen characters and <span style="color: #000000; font-weight: bold;">then</span> press Enter:
Characters remaining: <span style="color: #000000;">259</span>
Characters remaining: <span style="color: #000000;">190</span>
&nbsp;
&nbsp;
Done: <span style="color: #000000;">100.000</span><span style="color: #000000; font-weight: bold;">%</span>  Speed:  <span style="color: #000000;">7.0</span> MB<span style="color: #000000; font-weight: bold;">/</span>s  Left: <span style="color: #000000;">0</span> s          
&nbsp;
The TrueCrypt volume has been successfully created.</pre></div></div>

<p>From above, the volume&#8217;s path is: <strong>/root/my-crypt</strong><br />
Let mount it to a directory called <strong>encrypted-volume</strong> to start encrypting files.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>haider<span style="color: #000000; font-weight: bold;">/</span>encrypted-volume</pre></div></div>

<p>Now lets mount them.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">truecrypt <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>my-crypt <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>haider<span style="color: #000000; font-weight: bold;">/</span>encrypted-volume<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>This will open a gate to the encrypted volume, as such we must provide the correct password:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Enter password <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>my-crypt: 
Enter keyfile <span style="color: #7a0874; font-weight: bold;">&#91;</span>none<span style="color: #7a0874; font-weight: bold;">&#93;</span>: 
Protect hidden volume <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> any<span style="color: #7a0874; font-weight: bold;">&#41;</span>? <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">y</span>=Yes<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">n</span>=No<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>No<span style="color: #7a0874; font-weight: bold;">&#93;</span>: n</pre></div></div>

<p>From this point, to encrypt files just move them to the <strong>encrypted-volume</strong> directory. Once finished, demount the two to protect your files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">truecrypt <span style="color: #660033;">-d</span></pre></div></div>

<p>In the future, if you require access to your encrypted files, or if you want to encrypt more files in that volume. Mount it again. That&#8217;s all! <img src='http://blog.creativeitp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/cryptography/truecrypt-a-windowslinux-tool-to-encrypt-volumes-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure and use OpenSSH using password-based and/or public &amp; private key pairs between two Linux boxes (Ubuntu and CentOS)</title>
		<link>http://blog.creativeitp.com/posts-and-articles/linux/configure-and-use-openssh-using-password-based-andor-public-private-key-pairs-between-two-linux-boxes-ubuntu-and-centos-and-between-a-linax-box-and-windows/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/linux/configure-and-use-openssh-using-password-based-andor-public-private-key-pairs-between-two-linux-boxes-ubuntu-and-centos-and-between-a-linax-box-and-windows/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 15:53:19 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Remote Access]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=566</guid>
		<description><![CDATA[Unlike Telnet, Secure Shell (SSH) encrypts the connection between the remotely connected hosts and doesnt trransfer your password in plain text. As such SSH is more secure and must be used for remote connections. In this post I will install, configure and connect 2 computers running Ubuntu and CentOS. The connection will be tested with [...]]]></description>
			<content:encoded><![CDATA[<p>Unlike Telnet, Secure Shell (SSH) encrypts the connection between the remotely connected hosts and doesnt trransfer your password in plain text. As such SSH is more secure and must be used for remote connections. In this post I will install, configure and connect 2 computers running Ubuntu and CentOS. The connection will be tested with a password-based authentication followed by using public and private key pairs to establish trust between the hosts.</p>
<p>To start this trial, install OpenSSH server and client to Ubuntu using:<br />
<i>P.S. make sure you login as root when required.</i></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> openssh-client
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> openssh-server</pre></div></div>

<p><span id="more-566"></span><br />
To install them in CentOS use yum instead of apt-get:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> openssh-client
yum <span style="color: #c20cb9; font-weight: bold;">install</span> openssh-server</pre></div></div>

<p>After installation, lets refresh the service. In Ubuntu this is done using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> restart</pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">service <span style="color: #c20cb9; font-weight: bold;">ssh</span> restart</pre></div></div>

<p>While in CentOS the service is called sshd, so we use:</p>
<p>After installation, lets refresh the service. In Ubuntu this is done using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>sshd restart</pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">service sshd restart</pre></div></div>

<p>This should enable you now to connect to each system from the other one remotely. For instance, if the IP of CentOS system is 192.168.1.5 we may access it from Ubuntu using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> 192.168.1.5</pre></div></div>

<p>or if you want to login with a specific username such as &#8216;haider&#8217;, use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> haider<span style="color: #000000; font-weight: bold;">@</span>192.168.1.5</pre></div></div>

<p>For security reasons, you might wish to change the listening port number of the SSH service (the server, in our case is CentOS). This and other configurations are made inside the <b>/etc/ssh/sshd_config</b> file. However, before doing any changes it is a good practise to take a backup:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config.original</pre></div></div>

<p>Now edit the file using your favourite editor (vi, nano etc) and change the port from 22 to 2222 (or any other unused port). Once done restart the service again (the relevant command was mentioned above) to activate the new settings and use the following command to check the status of your new port:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-punat</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">&quot;2222&quot;</span></pre></div></div>

<p>To use the public key authentication, I used the following command to generate a private and a public key with RSA encryption in my Ubuntu</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span></pre></div></div>

<p>The Terminal will prompt you for a name for your keys, just press enter and the name will be id_rsa by default. These, once generated, are automatically stored in the directory you are in. As such I advice you to run it from the <strong>/root/.ssh</strong> directory to save it there. Running the command will produce two files: id_rsa (this is the private key and should remain safe in your machine) &#038; id_rsa.pub (which is the public key).</p>
<p>To allow ssh access using these keys the content of the public key must be copied to the <strong>~/.ssh/authorized_keys</strong> file on the server&#8217;s machine (CentOS). Since our ssh worked with password authentication, lets use <strong>scp</strong> (secure copy) to achieve this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub 192.168.1.5:~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Now, on CentOS copy the content of the public key into the authorized_keys file (you may create this file if it doesn&#8217;t exist).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> id_rsa.pub <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> authorized_keys</pre></div></div>

<p>Then, lets allow public key authentication inside CentOS ssh configuration file. Simply make sure the following lines are not commented-out:</p>
<p><strong>PubkeyAuthentication</strong> yes<br />
<strong>AuthorizedKeysFile</strong> .ssh/authorized_keys</p>
<p>Restart ssh service again on the server (CentOS).</p>
<p>Thats all! I can now connect to my CentOS system from Ubuntu without being prompt for a password. In fact I may disable password-based authentication.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/linux/configure-and-use-openssh-using-password-based-andor-public-private-key-pairs-between-two-linux-boxes-ubuntu-and-centos-and-between-a-linax-box-and-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving the Fibonacci Rabbit Puzzle using Java</title>
		<link>http://blog.creativeitp.com/posts-and-articles/java/solving-the-fibonacci-rabbit-puzzle-using-java/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/java/solving-the-fibonacci-rabbit-puzzle-using-java/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 15:30:01 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mathematics]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=559</guid>
		<description><![CDATA[Leonardo Fibonacci was a talented Italian mathematician. He is best known for a number sequence named after him known as the Fibonacci Numbers. These numbers take the following pattern: 0, 1, 1, 2, 3, 5, 8, 13, 21 &#8230; The series is formed by adding two numbers in the series to generate the third. The [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Leonardo Fibonacci</strong> was a talented Italian mathematician. He is best known for a number sequence named after him known as the <em>Fibonacci Numbers</em>.</p>
<p>These numbers take the following pattern:<br />
<strong>0, 1, 1, 2, 3, 5, 8, 13, 21 &#8230;</strong><br />
The series is formed by adding two numbers in the series to generate the third.</p>
<p>The Rabbit Puzzle that Fibonacci investigated in the year 1202 is a great example to introduce you to the significance of the Fibonacci number series.<span id="more-559"></span></p>
<p>Fibonacci&#8217;s Rabbits Puzzle was about calculating the number of rabbits if they mate and breed in ideal circumstances.  As such, the question was: &#8216;How many pairs of rabbits will be produced in a year, beginning with a single pair, if in every month each pair bears a new pair which becomes productive from the second month on?&#8217;</p>
<p>To investigate the matter, the following was assumed:</p>
<ul>
<li> Begin with a newly-born pair of rabbits, one male, one female. Rabbits can mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits.
<li> The rabbits never die.
<li> The female produces one male and one female every month.
</ul>
<p>The following Java code produces numbers following Fibonacci pattern. Feel free to edit the value of &#8216;stopAt&#8217; to extend the number of numbers being produced by the code. Have fun!</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FibonacciSeries
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> fibCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
       <span style="color: #000066; font-weight: bold;">int</span> n1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
       <span style="color: #000066; font-weight: bold;">int</span> n2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
       <span style="color: #000066; font-weight: bold;">int</span> n3<span style="color: #339933;">;</span>
	   <span style="color: #000066; font-weight: bold;">int</span> stopAt <span style="color: #339933;">=</span> <span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>stopAt<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
         n3 <span style="color: #339933;">=</span> n1<span style="color: #339933;">+</span>n2<span style="color: #339933;">;</span>
         <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         n1 <span style="color: #339933;">=</span> n2<span style="color: #339933;">;</span>
         n2 <span style="color: #339933;">=</span> n3<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        fibCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/java/solving-the-fibonacci-rabbit-puzzle-using-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sisco IOS CLI brief tutorial</title>
		<link>http://blog.creativeitp.com/posts-and-articles/networking/sisco-ios-cli-brief-tutorial/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/networking/sisco-ios-cli-brief-tutorial/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 13:18:21 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Sisco]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=528</guid>
		<description><![CDATA[You can remotely access a Sisco IOS (Internetworking Operating System) in what is knows as an EXEC session to control a router using its CLI (Command Line Interface). EXEC sessions are separated into a basic user EXEC level and a privileged EXEC level to run configuration and other critical commands. Critical Cisco Router configuration commands [...]]]></description>
			<content:encoded><![CDATA[<p>You can remotely access a Sisco IOS (Internetworking Operating System) in what is knows as an EXEC session to control a router using its CLI (Command Line Interface).</p>
<p>EXEC sessions are separated into a basic user EXEC level and a privileged EXEC level to run configuration and other critical commands.</p>
<p><u>Critical Cisco Router configuration commands</u><br />
<em>&#8216;&#8212;&#8212;&#8212;&#8212;&#8217; is used to prefix comments in this small tutorial</em></p>
<p><strong>Router><font color=red>enable</font></strong> &#8212;&#8212;&#8212;&#8212; enable is used to change into privileged level<br />
<strong>Password:</strong> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; if passwords is enabled<br />
<strong>Router#</strong> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- # means we are in privileged level<br />
<strong>Router#<font color=red>disable</font></strong> &#8212;&#8212;&#8212;&#8211; switch to user EXEC level<br />
<strong>Router></strong></p>
<p><strong>Router><font color=red>ping xxx.xxx.xxx.xxx</font></strong>	&#8212;&#8212;&#8212;&#8212; ping is supported</p>
<p>The <em>show</em> command is used to troubleshoot your Cisco router<br />
<span id="more-528"></span></p>
<p><strong>Router#<font color=red>show ?</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; display arguments<br />
<strong>Router#<font color=red>show interfaces</font><br />
Router#<font color=red>show ip protocols</font><br />
Router#<font color=red>show ipv6 protocols</font><br />
Router#<font color=red>show ip route</font><br />
Router#<font color=red>show ipv6 route	</font><br />
Router#<font color=red>show ip arp</font><br />
Router#<font color=red>show ipv6 neighbors</font></strong><br />
<strong>Router#<font color=red>show running-config</font></strong>&#8212;&#8212;&#8212;&#8212; display running-configuration<br />
<strong>Router#<font color=red>show startup-config</font></strong>&#8212;&#8212;&#8212;&#8212; display startup-configuration stored in NVRAM</p>
<p>P.S. typing &#8216;?&#8217; after a word directly (no space in between)  such as &#8216;co?&#8217; shows all command wards starting with co</p>
<p>The configuration mode</p>
<p><strong>Router#<font color=red>config</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; start config<br />
<strong>Router(config)#</strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; inside config mode<br />
<strong>Router(config)#<font color=red>hostname MyRouter</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- change router name to MyRouter<br />
<strong>MyRouter(config)#</strong><br />
<strong>MyRouter(config)#<font color=red>enable secret</font> [password]</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; set password for privileged level<br />
<strong>MyRouter(config)#<font color=red> no enable secret</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- remove password</p>
<p>Within config mode there are three levels. These are: interface, router and line.</p>
<p>Interface level example</p>
<p><strong>MyRouter(config)#<font color=red>interface FastEthernet0/1</font><br />
MyRouter(config-if)#<font color=red>ip address 192.168.0.1 255.255.255.0</font><br />
MyRouter(config-if)#<font color=red>ipv6 address fe80::230:1bff:fe80:b8ea/64</font><br />
MyRouter(config-if)#<font color=red>ipv6 enable</font></strong><br />
<strong>MyRouter(config-if)#<font color=red>no shutdown</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; to activate interface<br />
<strong>MyRouter(config-if)#ctrl-z</strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; ctrl-z is used to save&#038;exit</p>
<p>Routing engine level example</p>
<p><strong>MyRouter(config)#<font color=red> router rip</font></strong> &#8212;&#8212;&#8212;&#8212;&#8212;&#8211; to configure RIP (Routing Information Protocol) routing engine<br />
<strong>MyRouter(config-router)# <font color=red>network 192.168.4.0</font></strong>&#8212;&#8212;&#8212;&#8212; adds network 192.168.4.0 to RIP engine<br />
<strong>MyRouter(config-router)#<font color=red> network 192.168.5.0</font></strong>&#8212;&#8212;&#8212;&#8212; adds network 192.168.5.0 to RIP engine<br />
<strong>MyRouter(config-router)#<font color=red> exit</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- exits back to global configuration level</p>
<p><strong>MyRouter(config)#<font color=red>ip name-server xxx.xxx.xxx.xxx</font></strong>&#8212;&#8212;&#8212;&#8211; To specify the address of one or more name servers<br />
<strong>MyRouter(config)#<font color=red> ip route 0.0.0.0 0.0.0.0 20.2.2.3</font></strong>&#8212;&#8212;&#8212;&#8212; configures a static IP route (global)	</p>
<p>Line level (CTY, VTY, AUX, TTY/ASYNC) example</p>
<p>&#8216;Lines&#8217; on Cisco routers are physical or visual serial ports. For instance, the console (CTY) port is used to connect your computer to the router using a cable through a serial interface. This port require protection as such we should set a password for future connection attempts.</p>
<p><strong>MyRouter(config)#<font color=red>line con 0</font></strong><br />
<strong>MyRouter(config-line)#<font color=red>password</font> [password]</strong>&#8212;&#8212;&#8212;&#8212;- set a PW for the console line<br />
<strong>MyRouter(config-line)#<font color=red>login</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; activate login/password requirement<br />
<strong>MyRouter(config-line)#<font color=red>exit</font></strong></p>
<p>VTY ports are visual ports. As such, they are used for remote access using Telnet or SSH.<br />
The following examples demonstrate how to configure VTY ports in a Sisco router</p>
<p><strong>MyRouter(config)#<font color=red>line vty 0 4</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; typically there are 5 ports<br />
<strong>MyRouter(config-line)#<font color=red>password</font> [password]</strong>&#8212;&#8212;&#8212;&#8212;- set a PW for the Virtual Terminal Line<br />
<strong>MyRouter(config-line)#<font color=red>login</font></strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; activate login/password requirement<br />
<strong>MyRouter(config-line)#<font color=red>exit</font></strong></p>
<p>note, you may add &#8216;?&#8217; to learn last line number as in the following example</p>
<p><strong>MyRouter(config)#<font color=red>line vty 0 ?</font></strong><br />
<strong><1-4> Last Line Number</strong><br />
<strong>MyRouter(config)#</strong></p>
<p>An AUX port acts as a secondary console port.<br />
TTY/ASYNC exist only if the router has an ASYNC card.</p>
<p>Finally, make sure your new configurations will be perminant with the following command</p>
<p><strong>MyRouter# <font color=red>copy running-config startup-config</font></strong>	&#8212;&#8212;&#8212;&#8212; or &#8216;write memory&#8217; for old IOS prior to 11.x</p>
<p><u>References:</u></p>
<p>[1] Configure lines and VTYs on Cisco routers.</p>
<p>http://www.techrepublic.com/blog/networking/configure-lines-and-vtys-on-cisco-routers/409</p>
<p>[2] Cisco IOS Command Line Interface Tutorial. http://www.cisco.com/warp/cpropub/45/tutorial.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/networking/sisco-ios-cli-brief-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Methods to drag and resize your C# transparent WPF application with the WindowStyle property set to None</title>
		<link>http://blog.creativeitp.com/posts-and-articles/c-sharp/simple-methods-to-drag-and-resize-your-c-transparent-wpf-application-with-the-windowstyle-property-set-to-none/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/c-sharp/simple-methods-to-drag-and-resize-your-c-transparent-wpf-application-with-the-windowstyle-property-set-to-none/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 14:48:53 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=504</guid>
		<description><![CDATA[If your objective is to develop a software with highly customized Windows then start a new WPF application in Visual Studio (VS). Currently I am developing a new &#8216;Desktop Sticky Notes&#8217; software hence it is important that my windows (notes) are designed like an e-replica of a real sticky note on your desktop. As such [...]]]></description>
			<content:encoded><![CDATA[<p>If your objective is to develop a software with highly customized Windows then start a new WPF application in Visual Studio (VS). Currently I am developing a new &#8216;Desktop Sticky Notes&#8217; software hence it is important that my windows (notes) are designed like an e-replica of a real sticky note on your desktop.</p>
<p>As such I started a new WPF project, dragged a Grid control from the Toolbox and decided to set my WindowStyle property to None, AllowTransparency to True and finally ResizeMode to NoResize. These steps would generate the following XAML code in VS:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Window</span> <span style="color: #000066;">x:Class</span>=<span style="color: #ff0000;">&quot;WpfApplication1.MainWindow&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">xmlns:x</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">Title</span>=<span style="color: #ff0000;">&quot;MainWindow&quot;</span> <span style="color: #000066;">Height</span>=<span style="color: #ff0000;">&quot;350&quot;</span> <span style="color: #000066;">Width</span>=<span style="color: #ff0000;">&quot;525&quot;</span> <span style="color: #000066;">ResizeMode</span>=<span style="color: #ff0000;">&quot;NoResize&quot;</span> <span style="color: #000066;">AllowsTransparency</span>=<span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #000066;">Opacity</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">WindowStyle</span>=<span style="color: #ff0000;">&quot;None&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid</span> <span style="color: #000066;">Height</span>=<span style="color: #ff0000;">&quot;311&quot;</span> <span style="color: #000066;">HorizontalAlignment</span>=<span style="color: #ff0000;">&quot;Left&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;grid1&quot;</span> <span style="color: #000066;">VerticalAlignment</span>=<span style="color: #ff0000;">&quot;Top&quot;</span> <span style="color: #000066;">Width</span>=<span style="color: #ff0000;">&quot;503&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Window<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><span id="more-504"></span></p>
<p>Running this code will generate a white empty grid. Although we can now add any type of control, our layout  can not be resized! </p>
<p>It seems that there are currently no built-in methods in VS to accomplish this task. However, a suitable solution has been <a href="http://blog.kirupa.com/?p=256" target="_blank">posted online</a>. This code must be repeated for every window. I decided to develop the necessary piece of codes into a separate C# class to provide a reusable, easy-to-use methods to resize WPF transparent windows. In the following few steps I will explain how easily it is now to let your transparent windows resized on all corners and sides.</p>
<ol>
<li> From the Toolbox, use the Rectangle control to draw 4 borders and 4 corners around your Grid similar to Figure 1. For the code to work you must give these rectangles the following names appropriately: <strong>top</strong>, <strong>left</strong>, <strong>right</strong>, <strong>bottom</strong>, <strong>topLeft</strong>, <strong>topRight</strong>, <strong>bottomLeft</strong> and finally <strong>bottomRight</strong>. If you dont use these names, the code will not work!
<p>In addition, set the HorizontalAlignment, VerticalAlignment, Width and Height for each of the rectangles. Make sure you set them to Stretch and Auto when appropriate. For instance, the <strong>top</strong> rectangle will have HorizontalAlignment set to Stretch, VerticalAlignment set to Top, Width to Auto and Height to a suitable number such as 15.</p>
<div id="attachment_510" class="wp-caption aligncenter" style="width: 437px"><a href="http://blog.creativeitp.com/wp-content/uploads/2011/09/ResizableWindowWPF1.png"><img src="http://blog.creativeitp.com/wp-content/uploads/2011/09/ResizableWindowWPF1.png" alt="" title="ResizableWindowWPF1" width="427" height="278" class="size-full wp-image-510" /></a><p class="wp-caption-text">Figure 1</p></div>
<li> In your &#8216;Solution Explorer&#8217; right-click your project&#8217;s name (in my example it is WpfApplication1) to add a new C# file. Make sure you call it: <strong>WindowResizer.cs</strong> and replace its content with the following code:<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Controls</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Data</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Documents</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Input</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Media</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Media.Imaging</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Shapes</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Interop</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Runtime.InteropServices</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Diagnostics</span><span style="color: #008000;">;</span>
&nbsp;
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">class</span> WindowResizer
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">int</span> WM_SYSCOMMAND <span style="color: #008000;">=</span> 0x112<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> HwndSource hwndSource<span style="color: #008000;">;</span>
        Window activeWin<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> WindowResizer<span style="color: #008000;">&#40;</span>Window activeW<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            activeWin <span style="color: #008000;">=</span> activeW <span style="color: #0600FF; font-weight: bold;">as</span> Window<span style="color: #008000;">;</span>
&nbsp;
            activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">SourceInitialized</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> EventHandler<span style="color: #008000;">&#40;</span>InitializeWindowSource<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> resetCursor<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>Mouse<span style="color: #008000;">.</span><span style="color: #0000FF;">LeftButton</span> <span style="color: #008000;">!=</span> MouseButtonState<span style="color: #008000;">.</span><span style="color: #0000FF;">Pressed</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">Arrow</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> dragWindow<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">DragMove</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> InitializeWindowSource<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            hwndSource <span style="color: #008000;">=</span> PresentationSource<span style="color: #008000;">.</span><span style="color: #0000FF;">FromVisual</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>Visual<span style="color: #008000;">&#41;</span>sender<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> HwndSource<span style="color: #008000;">;</span>
            hwndSource<span style="color: #008000;">.</span><span style="color: #0000FF;">AddHook</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> HwndSourceHook<span style="color: #008000;">&#40;</span>WndProc<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        IntPtr retInt <span style="color: #008000;">=</span> IntPtr<span style="color: #008000;">.</span><span style="color: #0000FF;">Zero</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> IntPtr WndProc<span style="color: #008000;">&#40;</span>IntPtr hwnd, <span style="color: #6666cc; font-weight: bold;">int</span> msg, IntPtr wParam, IntPtr lParam, <span style="color: #0600FF; font-weight: bold;">ref</span> <span style="color: #6666cc; font-weight: bold;">bool</span> handled<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Debug<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;WndProc messages: &quot;</span> <span style="color: #008000;">+</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008080; font-style: italic;">//</span>
            <span style="color: #008080; font-style: italic;">// Check incoming window system messages</span>
            <span style="color: #008080; font-style: italic;">//</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>msg <span style="color: #008000;">==</span> WM_SYSCOMMAND<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                Debug<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;WndProc messages: &quot;</span> <span style="color: #008000;">+</span> msg<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> IntPtr<span style="color: #008000;">.</span><span style="color: #0000FF;">Zero</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">enum</span> ResizeDirection
        <span style="color: #008000;">&#123;</span>
            Left <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>,
            Right <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>,
            Top <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>,
            TopLeft <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>,
            TopRight <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span>,
            Bottom <span style="color: #008000;">=</span> <span style="color: #FF0000;">6</span>,
            BottomLeft <span style="color: #008000;">=</span> <span style="color: #FF0000;">7</span>,
            BottomRight <span style="color: #008000;">=</span> <span style="color: #FF0000;">8</span>,
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #008000;">&#91;</span>DllImport<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;user32.dll&quot;</span>, CharSet <span style="color: #008000;">=</span> CharSet<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Auto</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #0600FF; font-weight: bold;">extern</span> IntPtr SendMessage<span style="color: #008000;">&#40;</span>IntPtr hWnd, <span style="color: #6666cc; font-weight: bold;">uint</span> Msg, IntPtr wParam, IntPtr lParam<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection direction<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            SendMessage<span style="color: #008000;">&#40;</span>hwndSource<span style="color: #008000;">.</span><span style="color: #0000FF;">Handle</span>, WM_SYSCOMMAND, <span style="color: #008000;">&#40;</span>IntPtr<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">61440</span> <span style="color: #008000;">+</span> direction<span style="color: #008000;">&#41;</span>, IntPtr<span style="color: #008000;">.</span><span style="color: #0000FF;">Zero</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> resizeWindow<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Rectangle clickedRectangle <span style="color: #008000;">=</span> sender <span style="color: #0600FF; font-weight: bold;">as</span> Rectangle<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>clickedRectangle<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;top&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNS</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">Top</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;bottom&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNS</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">Bottom</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;left&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeWE</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">Left</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;right&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeWE</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">Right</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;topLeft&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNWSE</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">TopLeft</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;topRight&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNESW</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">TopRight</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;bottomLeft&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNESW</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">BottomLeft</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;bottomRight&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNWSE</span><span style="color: #008000;">;</span>
                    ResizeWindow<span style="color: #008000;">&#40;</span>ResizeDirection<span style="color: #008000;">.</span><span style="color: #0000FF;">BottomRight</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> displayResizeCursor<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
&nbsp;
            Rectangle clickedRectangle <span style="color: #008000;">=</span> sender <span style="color: #0600FF; font-weight: bold;">as</span> Rectangle<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>clickedRectangle<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;top&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNS</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;bottom&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNS</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;left&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeWE</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;right&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeWE</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;topLeft&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNWSE</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;topRight&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNESW</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;bottomLeft&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNESW</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;bottomRight&quot;</span><span style="color: #008000;">:</span>
                    activeWin<span style="color: #008000;">.</span><span style="color: #0000FF;">Cursor</span> <span style="color: #008000;">=</span> Cursors<span style="color: #008000;">.</span><span style="color: #0000FF;">SizeNWSE</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<li> Now that we added the WindowResizer class, we can make use of its methods to resize our window. View the code of your window class where you want to support resizing and do the following:
<ul>
<li> Initiate an object before the constructor: <strong>WindowResizer ob;</strong>
<li> Add the following line inside the constructor: <strong>ob = new WindowResizer(this);</strong>
<li> Then add the following methods (read the comment inside for further instructions):<br />
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// for each rectangle, assign the following method to its MouseEnter event.</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> DisplayResizeCursor<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, MouseEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
ob<span style="color: #008000;">.</span><span style="color: #0000FF;">displayResizeCursor</span><span style="color: #008000;">&#40;</span>sender<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008080; font-style: italic;">// for each rectangle, assign the following method to its MouseLeave event.</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> ResetCursor<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, MouseEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
ob<span style="color: #008000;">.</span><span style="color: #0000FF;">resetCursor</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008080; font-style: italic;">// for each rectangle, assign the following method to its PreviewMouseDown event.</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Resize<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, MouseButtonEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
ob<span style="color: #008000;">.</span><span style="color: #0000FF;">resizeWindow</span><span style="color: #008000;">&#40;</span>sender<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008080; font-style: italic;">// finally, you may use the following method to enable dragging!</span>
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> Drag<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, MouseButtonEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
ob<span style="color: #008000;">.</span><span style="color: #0000FF;">dragWindow</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

</ul>
<li> Click run to test your code, if everything has been done correctly you can now make the 8 rectangles transparent to have a neat look for your window. Of course you may reuse these methods for as many windows as you have as part of your project.<br />
</p>
<li> Finally, a working example (WPF Project) of the above steps can be <a href='http://blog.creativeitp.com/wp-content/uploads/2011/09/WpfApplication-WindowResizer.zip'>downloaded from here</a>!<br />
<br />
<em>GOOD LUCK</em>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/c-sharp/simple-methods-to-drag-and-resize-your-c-transparent-wpf-application-with-the-windowstyle-property-set-to-none/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First Fit Algorithm in java</title>
		<link>http://blog.creativeitp.com/posts-and-articles/java/first-fit-algorithm-in-java/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/java/first-fit-algorithm-in-java/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 23:27:16 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=433</guid>
		<description><![CDATA[First Fit algorithm is used to allocate jobs in the memory in arbitrary order. I will only explain it briefly assuming you wouldn&#8217;t be interested in the code unless you know what this algorithm is all about. It works by placing each job in the first memory block that can accommodate it (memory block is [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<div id="attachment_437" class="wp-caption aligncenter" style="width: 484px"><a href="http://blog.creativeitp.com/wp-content/uploads/2011/02/first-fit-algorithm.jpg"><img src="http://blog.creativeitp.com/wp-content/uploads/2011/02/first-fit-algorithm.jpg" alt="First Fit Algorithm" title="first-fit-algorithm" width="474" height="419" class="size-full wp-image-437" /></a><p class="wp-caption-text">First Fit Algorithm</p></div>
<p style="text-align: justify;">First Fit algorithm is used to allocate jobs in the memory in arbitrary order. I will only explain it briefly assuming you wouldn&#8217;t be interested in the code unless you know what this algorithm is all about. It works by placing each job in the first memory block that can accommodate it (<i>memory block is equal to or larger than job size</i>).<br /><span id="more-433"></span><br />
The job is sent to a waiting queue if it is larger than all available blocks!<br />
The following code is a Java implementation of the algorithm which I developed supported by few comments.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Implementation of a First Fit Alogrithm. A number of jobs are processed
 * if they are smaller or equal to the memory blocks. If the job is biger 
 * then it is sent to a waiting queue!
 * 
 * Author: Haider M. al-Khateeb 
 * Last Changed: 26/02/2011
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FirstFitAlgorithm
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">double</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> jobSize<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">double</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> memorySize<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// the number of memory blocks</span>
    <span style="color: #000066; font-weight: bold;">int</span> blocks<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// the number of jobs</span>
    <span style="color: #000066; font-weight: bold;">int</span> jobs<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">int</span> theCounter<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">int</span> jobIndex<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">int</span> jobInQueue<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setJobs<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> job1, <span style="color: #000066; font-weight: bold;">double</span> job2, <span style="color: #000066; font-weight: bold;">double</span> job3, <span style="color: #000066; font-weight: bold;">double</span> job4, <span style="color: #000066; font-weight: bold;">double</span> job5<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    jobSize <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">double</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// jobs</span>
    jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> job1<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// job 1</span>
    jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> job2<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// job 2</span>
    jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> job3<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// job 3</span>
    jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> job4<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// job 4</span>
    jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> job5<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// job 5</span>
    jobs <span style="color: #339933;">=</span> jobSize.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setMemory<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> memory1, <span style="color: #000066; font-weight: bold;">double</span> memory2, <span style="color: #000066; font-weight: bold;">double</span> memory3, <span style="color: #000066; font-weight: bold;">double</span> memory4, <span style="color: #000066; font-weight: bold;">double</span> memory5<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     memorySize <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">double</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//available memory blocks</span>
    memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> memory1<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// memory block 1</span>
    memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> memory2<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// memory block 2</span>
    memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> memory3<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// memory block 3</span>
    memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> memory4<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// memory block 4</span>
    memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> memory5<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// memory block 5</span>
    blocks <span style="color: #339933;">=</span> memorySize.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> firstFit<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> countr, <span style="color: #000066; font-weight: bold;">int</span> jobIndex<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
   theCounter <span style="color: #339933;">=</span> countr<span style="color: #339933;">;</span>
   jobIndex <span style="color: #339933;">=</span> jobIndex<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">do</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>jobSize<span style="color: #009900;">&#91;</span>jobIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> memorySize<span style="color: #009900;">&#91;</span>theCounter<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>  
            theCounter <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #009900;">&#123;</span> 
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;----------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Job &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>jobIndex<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; of size &quot;</span>  <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span>jobIndex<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; has been loaded into memory block:&quot;</span> <span style="color: #339933;">+</span> theCounter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        memorySize<span style="color: #009900;">&#91;</span>theCounter<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>memorySize<span style="color: #009900;">&#91;</span>theCounter<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span>jobSize<span style="color: #009900;">&#91;</span>jobIndex<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;The size of memory block &quot;</span> <span style="color: #339933;">+</span> theCounter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; is now &quot;</span> <span style="color: #339933;">+</span> memorySize<span style="color: #009900;">&#91;</span>theCounter<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        theCounter <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        jobIndex <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span>   <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>theCounter <span style="color: #339933;">&lt;=</span> blocks <span style="color: #339933;">&amp;&amp;</span> jobIndex <span style="color: #339933;">&lt;</span> jobs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;----------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  jobInQueue <span style="color: #339933;">=</span> jobIndex<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>jobInQueue <span style="color: #339933;">&lt;</span> jobs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Job &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>jobInQueue<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; of size &quot;</span> <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span>jobInQueue<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; is sent to waiting queue!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> showData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;==========================================================================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Available memory blocks are: (&quot;</span> <span style="color: #339933;">+</span> memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;), (&quot;</span> <span style="color: #339933;">+</span> memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;),(&quot;</span> <span style="color: #339933;">+</span> memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;), (&quot;</span> <span style="color: #339933;">+</span> memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;), (&quot;</span> <span style="color: #339933;">+</span> memorySize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;And jobs to allocate are: (&quot;</span> <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;), (&quot;</span> <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;),(&quot;</span> <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;), (&quot;</span> <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;), (&quot;</span> <span style="color: #339933;">+</span> jobSize<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;==========================================================================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;START&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;===========================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #009900;">&#123;</span>
&nbsp;
  FirstFitAlgorithm ob <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirstFitAlgorithm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  ob.<span style="color: #006633;">setJobs</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">64</span>,<span style="color: #cc66cc;">80</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">18</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set new jobs, change these values if you want</span>
  ob.<span style="color: #006633;">setMemory</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">70</span>,<span style="color: #cc66cc;">20</span>,<span style="color: #cc66cc;">20</span>,<span style="color: #cc66cc;">35</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// ser memory blocks, change these values if you want</span>
  ob.<span style="color: #006633;">showData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// display detail of available memory blocks and jobs to allocate </span>
  ob.<span style="color: #006633;">firstFit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ob.<span style="color: #006633;">jobInQueue</span> <span style="color: #339933;">&lt;</span> ob.<span style="color: #006633;">jobs</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      ob.<span style="color: #006633;">firstFit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #009900;">&#40;</span>ob.<span style="color: #006633;">jobInQueue</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/java/first-fit-algorithm-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google announces Iraq Domain (google.iq)</title>
		<link>http://blog.creativeitp.com/reference-library/google-announces-iraq-domain-google-iq/</link>
		<comments>http://blog.creativeitp.com/reference-library/google-announces-iraq-domain-google-iq/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 18:16:58 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Reference Library (Interesting News)]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=491</guid>
		<description><![CDATA[Two new Google domains: Iraq and Tunisia 3/31/2011 12:05:00 PM We offer search on different regional domains, such as google.fr for France and google.dj for Djibouti, in order to provide the most locally-relevant results. We&#8217;ve steadily brought Google to many of the world&#8217;s domains, and today we announced on our Google Arabia Blog that we&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Two new Google domains: Iraq and Tunisia</strong></p>
<p><em>3/31/2011 12:05:00 PM</em></p>
<p>We offer search on different regional domains, such as google.fr for France and google.dj for Djibouti, in order to provide the most locally-relevant results. We&#8217;ve steadily brought Google to many of the world&#8217;s domains, and today we announced on our Google Arabia Blog that we&#8217;re adding two more: google.iq for Iraq and google.tn for Tunisia. This brings the number of local Google search domains worldwide to 184, with 15 domains in Arab countries.</p>
<p>The new domains will help people in Iraq and Tunisia find locally relevant information, faster. For example, a search for [central bank] on the Iraq domain yields results relevant to someone in Iraq, such as the <span id="more-491"></span>Central Bank of Iraq. On the other hand, the same search on the Tunisia domain returns slightly different results. </p>
<p>The new domains also make it easier for people in Iraq and Tunisia to access search in their preferred languages. In Iraq, people can now easily access Google search in local languages like Arabic and Kurdish; while in Tunisia, people can find the Google interface in Arabic and French. In the past, people in these regions would need to visit the domain for another country to use Google in an interface they were comfortable with. And when they did, the results would be relevant to a different region.</p>
<p>Local domains are a first step towards making the web more accessible and relevant for people around the world. They’re also an integral part of our vision to make all of our products available in the world&#8217;s top 40 most spoken languages covering 99 percent of Internet users worldwide. We plan to add more domains in the coming months, so stay tuned! </p>
<p><em>Posted by AbdelKarim Mardini, Product Manager, Middle East &#038; North Africa</em></p>
<p>Ref. <a href="http://googleblog.blogspot.com/2011/03/two-new-google-domains-iraq-and-tunisia.html" target="_blank">http://googleblog.blogspot.com/2011/03/two-new-google-domains-iraq-and-tunisia.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/reference-library/google-announces-iraq-domain-google-iq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating an executable jar file for an applet</title>
		<link>http://blog.creativeitp.com/posts-and-articles/java/creating-an-executable-jar-file-for-an-applet/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/java/creating-an-executable-jar-file-for-an-applet/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 23:22:32 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=473</guid>
		<description><![CDATA[Few days ago I published (here) an applet to encrypt/decrypt Caesar&#8217;s cipher. An issue I faced was that an applet must be signed to access windows clipboard. However, a page with a singed applet welcomes you with a security warning! which I so want to avoid on my site. I think that visitors to my [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago I published (<a href="../cryptography/applet-implementation-to-code-caesars-substitution-cipher/" target="_blank">here</a>) an applet to encrypt/decrypt Caesar&#8217;s cipher. An issue I faced was that an applet must be signed to access windows clipboard. However, a page with a singed applet welcomes you with a security warning! which I so want to avoid on my site. I think that visitors to my blog should not be asked to deal with security messages from their system. The problem now is that users can not copy/paste text from and to the applet unless they run it on their local machines. As such, I thought the applet is functional and can be tested online and if any user require to copy/paste text (s)he may download the applet&#8217;s jar file and execute it locally whenever they want. Running the applet on your local machine does not include security restrictions on the code.</p>
<p>To create an executable a jar file there should be a main class (a class with a main method) inside the jar to run the software. An applet has no main method since it is usually designed to work inside a web browser. To make the jar file executable I had to do two things:</p>
<ul>
<li> <strong>One</strong></ul>
<p> I created a new class inside the jar file as a main class which I called <em>StartClass</em>. The job of this class is to call and host the applet; hence if the jar file is executed, the applet method is invoked. Check out the following code that I used supported by few comments to explain what it does.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">CaesarCodePackage</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StartClass <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// create an object of type CaesarCode which is the main applet class</span>
         CaesarCode theApplet <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CaesarCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         theApplet.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// invoke the applet's init() method</span>
         theApplet.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// starts the applet</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// Create a window (JFrame) and make applet the content pane.</span>
          javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JFrame</span> window <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JFrame</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Caesar's Cipher&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          window.<span style="color: #006633;">setContentPane</span><span style="color: #009900;">&#40;</span>theApplet<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          window.<span style="color: #006633;">setDefaultCloseOperation</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JFrame</span>.<span style="color: #006633;">EXIT_ON_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          window.<span style="color: #006633;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>              <span style="color: #666666; font-style: italic;">// Arrange the components.</span>
          window.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Make the window visible.</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<ul>
<li> <strong>Two</strong></ul>
<p> I had to edit the <strong>MANIFEST.MF</strong> file and add the following line to define my main class correctly<br />
<span id="more-473"></span><br />
<em>Main-Class: CaesarCodePackage.StartClass</em><br />
<br />
please note that &#8216;CaesarCodePackage&#8217; is my package&#8217;s name and &#8216;StartClass&#8217; is the name of my main class (the one with the main method that I used to call the applet). If this step is not performed correctly the following error is more likely to occur if you try to execute the jar file:</p>
<p><strong>Failed to load Main-Class manifest attribute</strong> &#8230;</p>
<p>A final note would be that, to successfully execute jar files on your system, you need to have JRE installed and the Jar files must be associated with <em>javax.exe</em> (javax.exe is located inside the bin directory of your JRE folder e.g. C:\Program Files\Java\jre6\bin) </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/java/creating-an-executable-jar-file-for-an-applet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Applet implementation to code Caesar&#8217;s substitution cipher</title>
		<link>http://blog.creativeitp.com/posts-and-articles/cryptography/applet-implementation-to-code-caesars-substitution-cipher/</link>
		<comments>http://blog.creativeitp.com/posts-and-articles/cryptography/applet-implementation-to-code-caesars-substitution-cipher/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 01:04:05 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Substitution Cipher]]></category>
		<category><![CDATA[Symmetric Encryption]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=454</guid>
		<description><![CDATA[In cryptography, Caesar cipher is one of the simplest encryption techniques. It is a substitution cipher in which each letter in the plaintext is replaced by a letter after a fixed number of positions down the alphabet. However, this applet shifts each character (letter, number of symbol) after a number of positions down the ASCII [...]]]></description>
			<content:encoded><![CDATA[<p>In cryptography, Caesar cipher is one of the simplest encryption techniques. It is a <i>substitution cipher</i> in which each letter in the plaintext is replaced by a letter after a fixed number of positions down the alphabet. However, this applet shifts each character (letter, number of symbol) after a number of positions down the <a href="http://en.wikipedia.org/wiki/ASCII" target="_blank">ASCII table</a>. Caesar&#8217;s cipher is categorised as a <i>symmetric encryption</i> and the secret key in this case is the number of shifts!</p>
<ul>
<li>To encrypt, select the encode mode, number of shifts and click Run.</ul>
<ul>
<li>You may encode a message multiple times.</ul>
<ul>
<li>To Decrypt, select the <span id="more-454"></span>decode mode and reverse your steps.</ul>
<p>
<div align="center">
<applet code="CaesarCodePackage/CaesarCode.class" archive="http://www.creativeitp.com/labs/caesar/CaesarCode.jar" width="400" height="400"><br />
    <font color=red><b>Cannot run Applet!</b></font><br />
	You do not have Java 2 JDK, Standard Edition v 1.5.0_05 support for APPLET!!<br />
</applet></div>
<p>
<font color=red><strong>IMPORTANT NOTICE:</strong></font> please note that I did not sign this applet so you may not be able to copy/paste text between the applet and your computer. To read more about this issue I posted another blog called: <a href="../java/creating-an-executable-jar-file-for-an-applet/" target="_blank">Creating an executable jar file for an applet</a>.<br />
If you like this piece of software, download the applet to your computer from <a href="http://www.creativeitp.com/labs/caesar/CaesarCode.jar" target="_blank">here</a> (executable jar file). Running the software on your system will solve the copy/paste problem. To successfully execute jar files on your system, you -of course- need to have the Java Runtime Environment (JRE) installed. If you still can not run the jar file, use the &#8216;Open with&#8217; option and select javax.exe (javax.exe is located inside the bin directory of your JRE folder e.g. C:\Program Files\Java\jre6\bin).</p>
<p>Further, here is the source code I developed for this applet for you to check and compile if you are interested. </p>
<p></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * CaesarCode.java
 *
 * By Haider al-Khateeb (http://blog.creativeitp.com)
 * Created on Mar 14, 2011.
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">CaesarCodePackage</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JOptionPane</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CaesarCode <span style="color: #000000; font-weight: bold;">extends</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JApplet</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> inputText<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">char</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> inputTextChr<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> inputTextInt<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">char</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> outputTextChr<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> intArray <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> cipher <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> plain <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> newLine <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;line.separator&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
             <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> inputText<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> inputText<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">inputText</span> <span style="color: #339933;">=</span> inputText<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getinputText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> inputText<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> convertToChar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
		inputTextChr <span style="color: #339933;">=</span> inputText.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> convertCharToInt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
		inputTextInt <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>inputTextChr.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>inputTextChr.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> inputTextInt2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> inputTextChr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> inputTextInt2<span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getIntArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>inputTextInt.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #009900;">&#123;</span>
			intArray <span style="color: #339933;">+=</span> inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> intArray<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> encrypt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> shift<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>inputTextInt.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                        <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>shift<span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">126</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>shift<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">126</span><span style="color: #339933;">-</span>inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">31</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>	inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> shift<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
		outputTextChr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span>inputTextInt.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>outputTextChr.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">char</span> outputTextChr2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#41;</span> inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			outputTextChr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> outputTextChr2<span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>outputTextChr.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			cipher <span style="color: #339933;">+=</span> outputTextChr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> cipher<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> decrypt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> shift<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>inputTextInt.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span>shift<span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">127</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>shift<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">32</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-=</span> shift<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		outputTextChr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span>inputTextInt.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>outputTextChr.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">char</span> outputTextChr2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#41;</span> inputTextInt<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			outputTextChr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> outputTextChr2<span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>outputTextChr.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			plain <span style="color: #339933;">+=</span> outputTextChr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> plain<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/** Initializes the applet CaesarCode */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            java.<span style="color: #006633;">awt</span>.<span style="color: #003399;">EventQueue</span>.<span style="color: #006633;">invokeAndWait</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Runnable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    initComponents<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */</span>
    @SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #666666; font-style: italic;">// &lt;editor-fold defaultstate=&quot;collapsed&quot; desc=&quot;Generated Code&quot;&gt;//GEN-BEGIN:initComponents</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> initComponents<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        jPanel1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jLabel1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jScrollPane1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JScrollPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jTextArea1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JTextArea</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jComboBox1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JComboBox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jLabel2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jLabel3 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jScrollPane2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JScrollPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jList1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton3 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton4 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton5 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jPanel1.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">102</span>, <span style="color: #cc66cc;">204</span>, <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jPanel1.<span style="color: #006633;">setBorder</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">BorderFactory</span>.<span style="color: #006633;">createEtchedBorder</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">102</span>, <span style="color: #cc66cc;">255</span>, <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jLabel1.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Input your message in the following box&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jTextArea1.<span style="color: #006633;">setColumns</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jTextArea1.<span style="color: #006633;">setLineWrap</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jTextArea1.<span style="color: #006633;">setRows</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jTextArea1.<span style="color: #006633;">setWrapStyleWord</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jScrollPane1.<span style="color: #006633;">setViewportView</span><span style="color: #009900;">&#40;</span>jTextArea1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jComboBox1.<span style="color: #006633;">setModel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">DefaultComboBoxModel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;Encode&quot;</span>, <span style="color: #0000ff;">&quot;Decode&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jLabel2.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Select mode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jLabel3.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">SwingConstants</span>.<span style="color: #006633;">RIGHT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jLabel3.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Number of shifts&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jList1.<span style="color: #006633;">setModel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">AbstractListModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> strings <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;01&quot;</span>, <span style="color: #0000ff;">&quot;02&quot;</span>, <span style="color: #0000ff;">&quot;03&quot;</span>, <span style="color: #0000ff;">&quot;04&quot;</span>, <span style="color: #0000ff;">&quot;05&quot;</span>, <span style="color: #0000ff;">&quot;06&quot;</span>, <span style="color: #0000ff;">&quot;07&quot;</span>, <span style="color: #0000ff;">&quot;08&quot;</span>, <span style="color: #0000ff;">&quot;09&quot;</span>, <span style="color: #0000ff;">&quot;10&quot;</span>, <span style="color: #0000ff;">&quot;11&quot;</span>, <span style="color: #0000ff;">&quot;12&quot;</span>, <span style="color: #0000ff;">&quot;13&quot;</span>, <span style="color: #0000ff;">&quot;14&quot;</span>, <span style="color: #0000ff;">&quot;15&quot;</span>, <span style="color: #0000ff;">&quot;16&quot;</span>, <span style="color: #0000ff;">&quot;17&quot;</span>, <span style="color: #0000ff;">&quot;18&quot;</span>, <span style="color: #0000ff;">&quot;19&quot;</span>, <span style="color: #0000ff;">&quot;20&quot;</span>, <span style="color: #0000ff;">&quot;21&quot;</span>, <span style="color: #0000ff;">&quot;22&quot;</span>, <span style="color: #0000ff;">&quot;23&quot;</span>, <span style="color: #0000ff;">&quot;24&quot;</span>, <span style="color: #0000ff;">&quot;25&quot;</span>, <span style="color: #0000ff;">&quot;26&quot;</span>, <span style="color: #0000ff;">&quot;27&quot;</span>, <span style="color: #0000ff;">&quot;28&quot;</span>, <span style="color: #0000ff;">&quot;29&quot;</span>, <span style="color: #0000ff;">&quot;30&quot;</span>, <span style="color: #0000ff;">&quot;31&quot;</span>, <span style="color: #0000ff;">&quot;32&quot;</span>, <span style="color: #0000ff;">&quot;33&quot;</span>, <span style="color: #0000ff;">&quot;34&quot;</span>, <span style="color: #0000ff;">&quot;35&quot;</span>, <span style="color: #0000ff;">&quot;36&quot;</span>, <span style="color: #0000ff;">&quot;37&quot;</span>, <span style="color: #0000ff;">&quot;38&quot;</span>, <span style="color: #0000ff;">&quot;39&quot;</span>, <span style="color: #0000ff;">&quot;40&quot;</span>, <span style="color: #0000ff;">&quot;41&quot;</span>, <span style="color: #0000ff;">&quot;42&quot;</span>, <span style="color: #0000ff;">&quot;43&quot;</span>, <span style="color: #0000ff;">&quot;44&quot;</span>, <span style="color: #0000ff;">&quot;45&quot;</span>, <span style="color: #0000ff;">&quot;46&quot;</span>, <span style="color: #0000ff;">&quot;47&quot;</span>, <span style="color: #0000ff;">&quot;48&quot;</span>, <span style="color: #0000ff;">&quot;49&quot;</span>, <span style="color: #0000ff;">&quot;50&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getSize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> strings.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> getElementAt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> strings<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jList1.<span style="color: #006633;">setSelectionMode</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">ListSelectionModel</span>.<span style="color: #006633;">SINGLE_SELECTION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jList1.<span style="color: #006633;">setVisibleRowCount</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jScrollPane2.<span style="color: #006633;">setViewportView</span><span style="color: #009900;">&#40;</span>jList1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jButton1.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Run&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton1.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                jButton1ActionPerformed<span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jButton2.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Help?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton2.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                jButton2ActionPerformed<span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jButton3.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Copy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton3.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                jButton3ActionPerformed<span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jButton4.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Paste&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton4.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                jButton4ActionPerformed<span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        jButton5.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Select All&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jButton5.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                jButton5ActionPerformed<span style="color: #009900;">&#40;</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span> jPanel1Layout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span><span style="color: #009900;">&#40;</span>jPanel1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jPanel1.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span>jPanel1Layout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jPanel1Layout.<span style="color: #006633;">setHorizontalGroup</span><span style="color: #009900;">&#40;</span>
            jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">19</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton2<span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">57</span>, <span style="color: #cc66cc;">57</span>, <span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jScrollPane2, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">58</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">29</span>, <span style="color: #cc66cc;">29</span>, <span style="color: #cc66cc;">29</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jScrollPane1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">TRAILING</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #cc66cc;">348</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">TRAILING</span>, jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">87</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span>, <span style="color: #cc66cc;">8</span>, <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span>, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
                            .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton3<span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addPreferredGap</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">LayoutStyle</span>.<span style="color: #006633;">ComponentPlacement</span>.<span style="color: #006633;">RELATED</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton4<span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addPreferredGap</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">LayoutStyle</span>.<span style="color: #006633;">ComponentPlacement</span>.<span style="color: #006633;">RELATED</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton5<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                            .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jLabel1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">278</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span>
                            .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">TRAILING</span>, jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">74</span>, <span style="color: #cc66cc;">74</span>, <span style="color: #cc66cc;">74</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jLabel3, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">45</span>, <span style="color: #cc66cc;">45</span>, <span style="color: #cc66cc;">45</span><span style="color: #009900;">&#41;</span>
                                .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
                                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jComboBox1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span>
                                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jLabel2, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">71</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                        .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">58</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">27</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        jPanel1Layout.<span style="color: #006633;">setVerticalGroup</span><span style="color: #009900;">&#40;</span>
            jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addContainerGap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">BASELINE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jLabel2, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jLabel3<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addPreferredGap</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">LayoutStyle</span>.<span style="color: #006633;">ComponentPlacement</span>.<span style="color: #006633;">RELATED</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton2<span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jScrollPane2, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jComboBox1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGap</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jLabel1<span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addPreferredGap</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">LayoutStyle</span>.<span style="color: #006633;">ComponentPlacement</span>.<span style="color: #006633;">RELATED</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>jPanel1Layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">BASELINE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton3, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton4, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
                    .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton5, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addPreferredGap</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">LayoutStyle</span>.<span style="color: #006633;">ComponentPlacement</span>.<span style="color: #006633;">RELATED</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jScrollPane1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span>, <span style="color: #cc66cc;">188</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">PREFERRED_SIZE</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addPreferredGap</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">LayoutStyle</span>.<span style="color: #006633;">ComponentPlacement</span>.<span style="color: #006633;">RELATED</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jButton1<span style="color: #009900;">&#41;</span>
                .<span style="color: #006633;">addContainerGap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span> layout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span><span style="color: #009900;">&#40;</span>getContentPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        getContentPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span>layout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        layout.<span style="color: #006633;">setHorizontalGroup</span><span style="color: #009900;">&#40;</span>
            layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jPanel1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        layout.<span style="color: #006633;">setVerticalGroup</span><span style="color: #009900;">&#40;</span>
            layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>jPanel1, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">DEFAULT_SIZE</span>, <span style="color: #003399;">Short</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">// &lt;/editor-fold&gt;//GEN-END:initComponents</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> jButton1ActionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//GEN-FIRST:event_jButton1ActionPerformed</span>
        <span style="color: #666666; font-style: italic;">// TODO add your handling code here:</span>
          <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>jList1.<span style="color: #006633;">getSelectedIndex</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
             <span style="color: #009900;">&#123;</span>
		CaesarCode msg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CaesarCode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">inputText</span><span style="color: #009900;">&#40;</span>jTextArea1.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		msg.<span style="color: #006633;">convertToChar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//convert plain text string to char data type</span>
		msg.<span style="color: #006633;">convertCharToInt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// convert char to their equivalent integer (decimal number) in the ASCCI table</span>
		<span style="color: #666666; font-style: italic;">//msg.getIntArray(); // show decimal numbers of the inputText</span>
		<span style="color: #000066; font-weight: bold;">int</span> shift <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">+</span> jList1.<span style="color: #006633;">getSelectedIndex</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>jComboBox1.<span style="color: #006633;">getSelectedItem</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Encode&quot;</span><span style="color: #009900;">&#41;</span>
			  <span style="color: #009900;">&#123;</span>
                                jTextArea1.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">encrypt</span><span style="color: #009900;">&#40;</span>shift<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                <span style="color: #666666; font-style: italic;">//  msg.encrypt(shift) = encrypt and output cipher</span>
			  <span style="color: #009900;">&#125;</span>
			   <span style="color: #000000; font-weight: bold;">else</span>
			  <span style="color: #009900;">&#123;</span>
				jTextArea1.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">decrypt</span><span style="color: #009900;">&#40;</span>shift<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                  <span style="color: #666666; font-style: italic;">//  msg.encrypt(shift) = decrypt and output cipher</span>
			  <span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;Please select a number of shifts first!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//GEN-LAST:event_jButton1ActionPerformed</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> jButton2ActionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//GEN-FIRST:event_jButton2ActionPerformed</span>
        <span style="color: #666666; font-style: italic;">// TODO add your handling code here:</span>
        <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;To encrypt, select the encode mode, the number of shifts and click ‘Run’.&quot;</span> <span style="color: #339933;">+</span> newLine <span style="color: #339933;">+</span>
                                            <span style="color: #0000ff;">&quot;You may encode the same message multiple times.&quot;</span> <span style="color: #339933;">+</span> newLine <span style="color: #339933;">+</span>
                                            <span style="color: #0000ff;">&quot;To Decrypt, select the decode mode and reverse your encryption steps.&quot;</span> <span style="color: #339933;">+</span> newLine <span style="color: #339933;">+</span> newLine <span style="color: #339933;">+</span>
                                            <span style="color: #0000ff;">&quot;By Haider al-Khateeb (http://blog.creativeitp.com)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//GEN-LAST:event_jButton2ActionPerformed</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> jButton3ActionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//GEN-FIRST:event_jButton3ActionPerformed</span>
        <span style="color: #666666; font-style: italic;">// TODO add your handling code here:</span>
        jTextArea1.<span style="color: #006633;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//GEN-LAST:event_jButton3ActionPerformed</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> jButton4ActionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//GEN-FIRST:event_jButton4ActionPerformed</span>
        <span style="color: #666666; font-style: italic;">// TODO add your handling code here:</span>
        jTextArea1.<span style="color: #006633;">paste</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//GEN-LAST:event_jButton4ActionPerformed</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> jButton5ActionPerformed<span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">awt</span>.<span style="color: #006633;">event</span>.<span style="color: #003399;">ActionEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//GEN-FIRST:event_jButton5ActionPerformed</span>
        <span style="color: #666666; font-style: italic;">// TODO add your handling code here:</span>
        jTextArea1.<span style="color: #006633;">selectAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//GEN-LAST:event_jButton5ActionPerformed</span>
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;">// Variables declaration - do not modify//GEN-BEGIN:variables</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span> jButton1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span> jButton2<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span> jButton3<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span> jButton4<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JButton</span> jButton5<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JComboBox</span> jComboBox1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JLabel</span> jLabel1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JLabel</span> jLabel2<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JLabel</span> jLabel3<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JList</span> jList1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JPanel</span> jPanel1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JScrollPane</span> jScrollPane1<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JScrollPane</span> jScrollPane2<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JTextArea</span> jTextArea1<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// End of variables declaration//GEN-END:variables</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/posts-and-articles/cryptography/applet-implementation-to-code-caesars-substitution-cipher/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>why 8-bits?</title>
		<link>http://blog.creativeitp.com/uncategorized/why-8-bits/</link>
		<comments>http://blog.creativeitp.com/uncategorized/why-8-bits/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 16:55:51 +0000</pubDate>
		<dc:creator>Haider al-Khateeb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Memory]]></category>

		<guid isPermaLink="false">http://blog.creativeitp.com/?p=443</guid>
		<description><![CDATA[A Byte is used to code a single character from the ASCII table. It was found that 7 bits are required to code any single ASCII character. However, computers use a binary (base-2) numeral system hence the size of the Byte was increased to the smallest power of 2 that could hold a single character [...]]]></description>
			<content:encoded><![CDATA[<p>A <i>Byte</i> is used to code a single character from the ASCII table. It was found that 7 bits are required to code any single ASCII character. However, computers use a binary (base-2) numeral system hence the size of the <i>Byte</i> was increased to the smallest power of 2 that could hold a single character which is 8.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creativeitp.com/uncategorized/why-8-bits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

