<?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>Threadbare Canvas Productions</title>
	<atom:link href="http://threadbarecanvas.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://threadbarecanvas.com</link>
	<description>Online Journal of James Hogan the Web Developer</description>
	<lastBuildDate>Sun, 01 Aug 2010 19:32:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>English Stop Words &#8211; Semantic Text Search</title>
		<link>http://threadbarecanvas.com/java-web/english-stop-words-semantic-text-search/</link>
		<comments>http://threadbarecanvas.com/java-web/english-stop-words-semantic-text-search/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 19:32:43 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=176</guid>
		<description><![CDATA[Weather your analyzing your blog comments or looking at a single sentence one of the best way to discover the meaning of a peice of text is to perform text stemming and stop word removal to be left with the bones of the text. This post is a list of those words in an array [...]]]></description>
			<content:encoded><![CDATA[<p>Weather your analyzing your blog comments or looking at a single sentence one of the best way to discover the meaning of a peice of text is to perform text stemming and stop word removal to be left with the bones of the text. This post is a list of those words in an array string format. yay.</p>
<pre class="brush:javascript">
["a","able","about","above","abst","accordance","according","accordingly","across","act","actually",
"added","adj","adopted","affected","affecting","affects","after","afterwards","again","against","ah","all",
"almost","alone","along","already","also","although","always","am","among","amongst","an","and","announce",
"another","any","anybody","anyhow","anymore","anyone","anything","anyway","anyways","anywhere",
"apparently","approximately","are","aren","arent","arise","around","as","aside","ask","asking","at","auth",
"available","away","awfully","b","back","be","became","because","become","becomes","becoming","been",
"before","beforehand","begin","beginning","beginnings","begins","behind","being","believe","below","beside",
"besides","between","beyond","biol","both","brief","briefly","but","by","c","ca","came","can","cannot","can't",
"cause","causes","certain","certainly","co","com","come","comes","contain","containing","contains","could",
"couldnt","d","date","did","didn't","different","do","does","doesn't","doing","done","don't","down","downwards",
"due","during","e","each","ed","edu","effect","eg","eight","eighty","either","else","elsewhere","end","ending",
"enough","especially","et","et-al","etc","even","ever","every","everybody","everyone","everything","everywhere","ex","except","f",
"far","few","ff","fifth","first","five","fix","followed","following","follows","for","former","formerly","forth","found",
"four","from","further","furthermore","g","gave","get","gets","getting","give","given","gives","giving","go","goes",
"gone","got","gotten","h","had","happens","hardly","has","hasn't","have","haven't","having","he","hed","hence",
"her","here","hereafter","hereby","herein","heres","hereupon","hers","herself","hes","hi","hid","him","himself","his",
"hither","home","how","howbeit","however","hundred","i","id","ie","if","i'll","im","immediate","immediately",
"importance","important","in","inc","indeed","index","information","instead","into","invention","inward","is","isn't",
"it","itd","it'll","its","itself","i've","j","just","k","keep","        keeps","kept","keys","kg","km","know","known","knows","l","largely","last","lately","later","latter","latterly",
"least","less","lest","let","lets","like","liked","likely","line","little","'ll","look","looking","looks","ltd","m","made",
"mainly","make","makes","many","may","maybe","me","mean","means","meantime","meanwhile","merely","mg",
"might","million","miss","ml","more","moreover","most","mostly","mr","mrs","much","mug","must","my","myself","n",
"na","name","namely","nay","nd","near","nearly","necessarily","necessary","need","needs","neither","never",
"nevertheless","new","next","nine","ninety","no","nobody","non","none","nonetheless","noone","nor","normally",
"nos","not","noted","nothing","now","nowhere","o","obtain","obtained","obviously","of","off","often","oh","ok",
"okay","old","omitted","on","once","one","ones","only","onto","or","ord","other","others","otherwise","ought",
"our","ours","ourselves","out","outside","over","overall","owing","own","p","page","pages","part","particular",
"particularly","past","per","perhaps","placed","please","plus","poorly","possible","possibly","potentially","pp",
"predominantly","present","previously","primarily","probably","promptly","proud","provides","put","q","que",
"quickly","quite","qv","r","ran","rather","rd","re","readily","really","recent","recently","ref","refs","regarding",
"regardless","regards","related","relatively","research","respectively","resulted","resulting","results","right","run",
"s","said","same","saw","say","saying","says","sec","section","see","seeing","seem","seemed","seeming","seems",
"seen","self","selves","sent","seven","several","shall","she","shed","she'll","shes","should","shouldn't","show",
"showed","shown","showns","shows","significant","significantly","similar","similarly","since","six","slightly","so",
"some","somebody","somehow","someone","somethan","something","sometime","sometimes","somewhat",
"somewhere","soon","sorry","specifically","specified","specify","specifying","state","states","still","stop",
"strongly","sub","substantially","successfully","such","sufficiently","suggest","sup","sure","        t","take","taken","taking","tell","tends","th","than","thank","thanks","thanx","that","that'll","thats","that've",
"the","their","theirs","them","themselves","then","thence","there","thereafter","thereby","thered","therefore",
"therein","there'll","thereof","therere","theres","thereto","thereupon","there've","these","they","theyd","they'll",
"theyre","they've","think","this","those","thou","though","thoughh","thousand","throug","through","throughout",
"thru","thus","til","tip","to","together","too","took","toward","towards","tried","tries","truly","try","trying","ts",
"twice","two","u","un","under","unfortunately","unless","unlike","unlikely","until","unto","up","upon","ups","us",
"use","used","useful","usefully","usefulness","uses","using","usually","v","value","various","'ve","very","via","viz",
"vol","vols","vs","w","want","wants","was","wasn't","way","we","wed","welcome","we'll","went","were","weren't",
"we've","what","whatever","what'll","whats","when","whence","whenever","where","whereafter","whereas",
"whereby","wherein","wheres","whereupon","wherever","whether","which","while","whim","whither","who",
"whod","whoever","whole","who'll","whom","whomever","whos","whose","why","widely","willing","wish","with",
"within","without","won't","words","world","would","wouldn't","www","x","y","yes","yet","you","youd","you'll",
"your","youre","yours","yourself","yourselves","you've","z","zero"]
</pre>
<p>The following is the simpe program that i used to convert a text file of these Stop words into the array string above.</p>
<pre class="brush:java">
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package arrayify;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Siriquelle
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        try
        {
            BufferedReader in = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("StopWords.txt")));
            String str = "";
            StringBuilder sb = new StringBuilder();
            while ((str = in.readLine()) != null)
            {
                sb.append("\"").append(str).append("\"");
            }
            str = sb.toString().replaceAll("\"\"", "\",\"");
            System.out.print(str);
            in.close();
        } catch (IOException e)
        {
            System.out.print(e.toString());
        }
    }
}
</pre>
<p>Hope this saves you some time. Many thanks to &lt;a href=&#8221;http://www.ranks.nl/resources/stopwords.html&#8221; &gt;http://www.ranks.nl/resources/stopwords.html &lt;/a&gt; for the list of words.</p>
<p><map name='google_ad_map_176_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/176?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_176_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=176&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Fenglish-stop-words-semantic-text-search%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/english-stop-words-semantic-text-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Python to determine if a number is whole or decimal</title>
		<link>http://threadbarecanvas.com/tutorial/using-python-will-determine-if-a-number-is-whole-or-decimal/</link>
		<comments>http://threadbarecanvas.com/tutorial/using-python-will-determine-if-a-number-is-whole-or-decimal/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:55:31 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[example]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=152</guid>
		<description><![CDATA[Introduction
In this example you will learn how to create a Python application that will determine if a given number is whole or decimal.
Step One: Download Python
Python is a cool language. Like Ruby it&#8217;s very simple to use. You can download it from the python site. Choose your version, download, install and move onto step two.
Step [...]]]></description>
			<content:encoded><![CDATA[<h4>Introduction</h4>
<p>In this example you will learn how to create a Python application that will determine if a given number is whole or decimal.</p>
<h4>Step One: Download Python</h4>
<p>Python is a cool language. Like Ruby it&#8217;s very simple to use. You can download it from <a href="http://www.python.org/download/">the python site</a>. Choose your version, download, install and move onto step two.</p>
<h4>Step Two: Simple Python Function</h4>
<p>Python functions are defined using the def keyword. In this example we define an isWhole function to check weather the number entered by the user is whole or not.</p>
<p><em>Code:</em></p>
<pre class="brush:python">def isWhole(x):
	if(x%1 == 0):
		return True
	else:
		return False
</pre>
<p>You&#8217;ll notice that after the function definition there is a colon and there are no semi colons at the end of lines. This is because indention is used to perform code blocks. Using indented code blocks, it is thought, will make the code easier to read.</p>
<h4>Step Three: Desktop application</h4>
<p>Copy and paste the following code into your favourite text editor. I use <a href="http://sourceforge.net/projects/notepad-plus/files/">Notepad++</a> for, like, everything. It really is a very good text editor. Make sure you save it as a .py file. Then, you should be able to run this file by double clicking it. If something goes wrong you micht want to re-st-ar-t your computer. But that&#8217;s it. You&#8217;ve got a start with python.</p>
<p><strong>NOTE:</strong> The first line you&#8217;ll see is commented out &#8216;#!/usr/bin/python&#8217; this is only used my Unix machines and is used for specifying the location of the python install. You may want to edit this line if you are using a Mac or Linux machine. But if you are, chances are, you knew that already.</p>
<p><em>Code:</em></p>
<pre class="brush:python">#!/usr/bin/python
# Filename: run.py

print '*******************'
print #
print '|   Welcome to Python   |'
print #

def isWhole(x):
	if(x%1 == 0):
		return True
	else:
		return False

#The scope of the following while loop
#is determined by the indentation. Spooky huh.
while(True):
	print '*******************'
	print #
	print 'Enter a number and i\'ll tell\nyou if its whole or not:'
	print #

#The function raw_input('Your number please: ') accepts
#raw input from the user. In this case we cast the raw
#input as a float and pass the input to the isWhole function.
	if(isWhole(float(raw_input('Your number please: ')))):
		print #
		print 'Well, this is clearly a whole number.'
	else:
		print #
		print 'Ick, I dont like decimal numbers'

	print #
	print '*******************'
	print #

#The following conditional statement will break out of the while
#loop we are in now, and terminate the program if the user enters N.
#the upper() funciton converts the users input to
#uppercase so that it compares to the N.
	if(raw_input('Would you like to try another number?(Y/N) ').upper() == 'N'):
		break
	print #
</pre>
<h4>Conclusion</h4>
<p>Now that you have this application up and running you can answer that is this a decimal or whole number question with confidence.</p>
<p><map name='google_ad_map_152_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/152?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_152_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=152&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Ftutorial%2Fusing-python-will-determine-if-a-number-is-whole-or-decimal%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/tutorial/using-python-will-determine-if-a-number-is-whole-or-decimal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write a Bouncing Accordian with JQuery</title>
		<link>http://threadbarecanvas.com/jquery/write-a-bouncing-accordian-with-jquery/</link>
		<comments>http://threadbarecanvas.com/jquery/write-a-bouncing-accordian-with-jquery/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 19:40:05 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=142</guid>
		<description><![CDATA[The following example is of a bouncing accordian. The idea behind a bouncing accordian is to use ajax to pull content for a number of pages and populate a central div with that data. The content area on the main page will fade out resize to 0px and then rsize again back to a new [...]]]></description>
			<content:encoded><![CDATA[<p>The following example is of a bouncing accordian. The idea behind a bouncing accordian is to use ajax to pull content for a number of pages and populate a central div with that data. The content area on the main page will fade out resize to 0px and then rsize again back to a new height with the new content displayed. The following is the result of the labour.</p>
<p><a href="http://threadbarecanvas.com/wp-content/uploads/2009/11/bouncing.png"><img class="aligncenter size-full wp-image-143" title="_bouncing" src="http://threadbarecanvas.com/wp-content/uploads/2009/11/bouncing.png" alt="_bouncing" width="480" height="261" /></a></p>
<p style="text-align: center; font-size: 24px;"><strong><a title="Write a Bouncing Accordian with JQuery" href="http://threadbarecanvas.com/wp-content/uploads/2009/11/15.zip" target="_blank">Source</a> <a title="Write a Bouncing Accordian with JQuery" href="http://threadbarecanvas.com/wp-content/uploads/2009/11/15/index.html" target="_blank">Demo</a></strong></p>
<p>So, now that you&#8217;ve had a peek at it working you can look over the code. The first thing is folder structure. I like base folder &gt; assets &gt; and then folders for each asset like &gt; ajax for the pages of content and css for css and so on. The following is the HTML and JQUERY all on one page as its fairly simple to put together.</p>
<pre class="brush:html">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" &gt;

	&lt;head&gt;
		&lt;title&gt;
			Bouncing Accordian
		&lt;/title&gt;
		&lt;link rel="shortcut icon" type="image/x-icon" href="assets/img/favicon.ico" /&gt;
		&lt;link rel="stylesheet" type="text/css" media="screen" href="assets/css/style.css" /&gt;
		&lt;script type="text/javascript" src="assets/js/jquery.js"&gt;&lt;/script&gt;
		&lt;script type="text/javascript" charset="utf-8"&gt;</pre>
<pre class="brush:javascript">		 $(document).ready(function() {

			$('#nav_list li').live('click', function(e) {
				loadContent(e.target.id);
			});

			function loadContent(pgNum){

					$('#ajax').animate({'height' : '0px', opacity : 0}, 1000, function(){
						//console.log($('#'+this.id).height());
						$('#'+this.id).load('assets/ajax/' + pgNum + '.html', function(){
						$('#'+this.id).animate({'height' : '420px' , opacity : 1}, 1000);
						});
					});
			}

			});</pre>
<pre class="brush:html">		&lt;/script&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;div id="main"&gt;

			&lt;div id="container" class="aligncenter"&gt;

				&lt;div id="nav"&gt;
					&lt;ul id="nav_list" class="aligncenter"&gt;
						&lt;li id="page1" &gt;Home&lt;/li&gt;
						&lt;li id="page2"&gt;About&lt;/li&gt;
						&lt;li id="page3"&gt;Contact&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/div&gt;

				&lt;div id="content"&gt;
					&lt;div id="ajax"&gt;
						&lt;img src="http://bulk.destructoid.com/ul/122540-hands-on-yakuza-3-japanese-demo/wow-468x.jpg" width="460px"/&gt;
					&lt;/div&gt;
				&lt;/div&gt;

				&lt;div id="footer"&gt;
				&lt;div&gt;© Threadbare Canvas Productions &amp; James Hogan&lt;/div&gt;
				&lt;/div&gt;

			&lt;/div&gt;

		&lt;/div&gt;

	&lt;/body&gt;
&lt;/html&gt;</pre>
<p>That was easy, a couple of lines of jquery and youve got a neat effect. Add some CSS for Style.</p>
<pre class="brush: css">
body{margin:0; padding:0px; background-color: #bdbdbd;}
a{text-decoration:inherit; color: inherit;}
.aligncenter{margin-left:auto;margin-right:auto;}

#main{
background-color:#dedede;
font-family:arial;
}

#container{
width:480px;
background-color:#dedede;
}

#nav{
border:5px #efefef solid;
-moz-border-radius:15px;
}
#nav #nav_list{
width:355px;
}

#nav #nav_list li{
display:inline;
margin-left:30px;
padding:5px;
border:1px #ccc outset;
background-color:#cdcdcd;
color:#fefefe;
-moz-border-radius:10px;
font-weight:bold;
cursor:pointer;
}

#content{
-moz-border-radius:15px;
min-height:0px;
padding:5px;
border-left: 5px #efefef solid;
border-right: 5px #efefef solid;
}
#content h1{
font-size:18px;
}
#content p{
font-size:14px;
}

#footer{
-moz-border-radius:15px;
border: 5px #efefef solid;
padding:5px;
text-align:center;
font-size:12px;
}
</pre>
<p>Also there are three other pages those are the ajax pages that will be dragged in to fill the content area.. So I created three files page1, page2, page3 .html and put them in an ajax folder then I gave an id of page1, page2, page3 to each of the buttons that i wanted to activate the ajax request for the content. The following is the sample content I had in those files.</p>
<pre class="brush:html">
&lt;h1&gt;Home&lt;/h1&gt;

&lt;p&gt;Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis &lt;/p&gt;

&lt;p&gt;et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci &lt;/p&gt;

&lt;p&gt;velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea&lt;/p&gt;

&lt;p&gt; commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate&lt;/p&gt;

&lt;p&gt; velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?&lt;/p&gt;
</pre>
<p>And there you have it a few simple files and a few lines of jquery can create a really nice effect for a website. Even if it looks fuggley :). PEACE!!</p>
<p><map name='google_ad_map_142_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/142?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_142_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=142&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjquery%2Fwrite-a-bouncing-accordian-with-jquery%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/jquery/write-a-bouncing-accordian-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Putting Together a Javascript Hangman Game</title>
		<link>http://threadbarecanvas.com/javascript/putting-together-a-javascript-hangman-game/</link>
		<comments>http://threadbarecanvas.com/javascript/putting-together-a-javascript-hangman-game/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 12:07:42 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=133</guid>
		<description><![CDATA[Learning how to manipulate stings is an important component of being able to build usable web applications. The develoepr must be able to take in some input, process it and return to the ser some form of meaningful output.
In this example you will get four files. This is what your game will look like when [...]]]></description>
			<content:encoded><![CDATA[<p>Learning how to manipulate stings is an important component of being able to build usable web applications. The develoepr must be able to take in some input, process it and return to the ser some form of meaningful output.</p>
<p>In this example you will get four files. This is what your game will look like when it&#8217;s finished:</p>
<p><a href="http://threadbarecanvas.com/wp-content/uploads/2009/10/hangman.png"><img class="aligncenter size-full wp-image-134" title="hangman" src="http://threadbarecanvas.com/wp-content/uploads/2009/10/hangman.png" alt="hangman" width="199" height="557" /></a></p>
<p style="text-align: center; font-size: 24px;"><strong><a title="Putting Together a Javascript Hangman Game" href="http://threadbarecanvas.com/wp-content/uploads/2009/10/io1.zip" target="_blank">Source</a> <a title="Putting Together a Javascript Hangman Game" href="http://threadbarecanvas.com/wp-content/uploads/2009/10/hangman/hangman.htm" target="_blank">Demo</a></strong></p>
<p>So there you have it, a lovley hangman game to develop further and impress your friends with. The following is the code to the other files contained within the source folder.</p>
<p>First off let me show you hangman.htm</p>
<pre class="brush:html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Hangman&lt;/title&gt;
        &lt;link type="text/css" rel="stylesheet" media="screen" href="assets/css/style.css" /&gt;
        &lt;script type="text/JavaScript" src="assets/js/script.js" &gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="container"&gt;
            &lt;div id="head"&gt;&lt;a name="_top"&gt;Get ready to play&lt;/a&gt;&lt;/div&gt;
            &lt;div id="body"&gt;
                &lt;div id="body_head"&gt;Hangman&lt;/div&gt;

                &lt;div id="body_image"&gt;
                    &lt;script&gt;
                        if (window.innerWidth == null) {
                            intWidth = document.body.clientWidth;
                            intHeight = document.body.clientHeight;
                        }
                        else {
                            intWidth = window.innerWidth;
                            intHeight = window.innerHeight;
                        }
                        if (intWidth &gt;= intHeight) {
                            intHeight = Math.round(intHeight * 0.4);
                            intWidth = Math.round(180 * intHeight / 240);
                        }
                        else {
                            intWidth = Math.round(intWidth * 0.4);
                            intHeight = Math.round(240 * intWidth / 180);
                        }
                        doc.write('&lt;img name="PicHang" src="assets/images/Hangman_11.jpg" width="' + intWidth + '" height="' + intHeight + '" id="PicHang" alt="PicHang"/&gt;');
                    &lt;/script&gt;
                    &lt;noscript&gt;You do not appear to have JavaScript capabilities. This game is written in JavaScript.&lt;/noscript&gt;

                &lt;/div&gt;

                &lt;div id="body_footer"&gt;Don't Get Dead!!&lt;/div&gt;
            &lt;/div&gt;
            &lt;div id="response"&gt;
                &lt;form name="Game" action="./hangman.htm" method="post"&gt;
                    &lt;input type="text" name="TWord" id="TWord" /&gt;
                    &lt;label for="TGuess"&gt;What's your guess?&lt;/label&gt;
                    &lt;input type="text" name="TGuess" id="TGuess" maxlength="1" /&gt;
                    &lt;input type="text" name="TAnswer" id="TAnswer" /&gt;

                    &lt;input type="button" class="action_buttons" name="check" id="check" onclick="CheckGuess();" value="Check" &gt;
                    &lt;input type="button" class="action_buttons" name="start" id="start" onclick="StartOver();" value="Start" &gt;

                    &lt;input type="text" name="TMessage" id="TMessage" /&gt;
                    &lt;label for="TGuess"&gt;You have used the following letters:&lt;/label&gt;
                    &lt;input type="text" name="TPrevious" id="TPrevious" /&gt;
                &lt;/form&gt;
            &lt;/div&gt;
            &lt;div id="guess"&gt;

            &lt;/div&gt;
            &lt;div id="footer"&gt;
                &lt;script&gt;document.write('&lt;a href="#_top" onClick="javascript:ShowHelp()" &gt;HELP&lt;/a&gt;');&lt;/script&gt;
                &lt;noscript&gt;&lt;hr /&gt;
                    You do not appear to have JavaScript capabilities. This game is written in JavaScript.
                &lt;/noscript&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Next up, is the help file that we will be using javascript to open in a new window, help_popup.htm</p>
<pre class="brush:html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Hangman&lt;/title&gt;
        &lt;link type="text/css" rel="stylesheet" media="screen" href="assets/css/style.css" /&gt;
		&lt;script type="text/JavaScript"&gt;
			function closeWindow(){
				window.close();
			}
		&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="container"&gt;
            &lt;div id="head"&gt;help&lt;/div&gt;
			&lt;p&gt;boy am i glad that hangman is over... still some things bothering me, i'll get back to them,&lt;/p&gt;
            &lt;p&gt;&lt;a target="_parent" href="#head" onClick="javascript:closeWindow();" &gt;close&lt;/a&gt;&lt;/p&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>This is the interesting file, script.js</p>
<pre class="brush:javascript">window.onload = init();
var doc = document;
var p;
var preLoad;
var curWord;
var word;
var curPic = -1;
var count = 0;
var gcount = 0;

function init(){
    var Pic = new Array();	  //Declare the new array
    Pic[0] = 'assets/images/Hangman_1.jpg'; //Assign values to each element of
    Pic[1] = 'assets/images/Hangman_2.jpg'; //the array
    Pic[2] = 'assets/images/Hangman_3.jpg';
    Pic[3] = 'assets/images/Hangman_4.jpg';
    Pic[4] = 'assets/images/Hangman_5.jpg';
    Pic[5] = 'assets/images/Hangman_6.jpg';
    Pic[6] = 'assets/images/Hangman_7.jpg';
    Pic[7] = 'assets/images/Hangman_8.jpg';
    Pic[8] = 'assets/images/Hangman_9.jpg';
    Pic[9] = 'assets/images/Hangman_10.jpg';
    Pic[10] = 'assets/images/Hangman_11.jpg';

    p = Pic.length;
    preLoad = new Array();
    for(var i = 0; i &lt; p; i++){
        preLoad[i] = new Image();
        preLoad[i].src = Pic[i];
    }

//add new words as you see fit the application will adapt to the new words.
    word = new Array();
    word[0] = 'JOKER';
    word[1] = 'TYPICAL';
    word[2] = 'GOOGLE';

    curWord = Math.floor(Math.random() * word.length)+1;
    StartOver;
}

function CheckGuess(){
    var curGuess = doc.Game.TGuess.value;

    if(count &lt; 10){         if (curGuess != '' &amp;&amp; curGuess != ' '){             var curPos = word[curWord].indexOf(curGuess.toUpperCase());             var nomPos = doc.Game.TWord.value.indexOf(curGuess);             if (curPos &gt;= 0){

                //doc.Game.TMessage.value = doc.Game.TWord.value + ' ' + curGuess + ' ' + gcount + ' ';

                if(nomPos &gt;= 0){

                    do{
                        gcount = gcount-1;
                        nomPos = doc.Game.TWord.value.indexOf(curGuess, (nomPos+1));
                    }while(nomPos &gt; 0);
                //doc.Game.TMessage.value += ' ' + gcount + ' ' + doc.Game.TWord.value.indexOf(curGuess);
                }

                do{
                    gcount++;
                    doc.Game.TWord.value = DeBlankMachine(curWord, curPos, curGuess, doc.Game.TWord.value);
                    curPos = word[curWord].indexOf(curGuess.toUpperCase(), (curPos+1));
                } while(curPos &gt; 0);
            }else{
                count++;
                if(doc.Game.TPrevious.value.indexOf(curGuess) &gt;= 0){
                    count = count-1;
                }else{
                    doc.PicHang.src = preLoad[++curPic].src;
                    doc.Game.TPrevious.value += curGuess + ' ';
                }
            }
        }
    }else{
        doc.Game.TAnswer.value= word[curWord];
        doc.Game.TMessage.value = 'You Died, Press Start';
    }

    if(gcount == word[curWord].length){
        doc.Game.TAnswer.value= word[curWord];
        doc.Game.TMessage.value = 'You Win, Press Start';
        curPic = 11;
    }
    doc.Game.TGuess.value = '';

}

function StartOver(){
    curPic = 0;
    count = 0;
    gcount=0;
    doc.PicHang.src = preLoad[0].src;
    doc.Game.TGuess.value = '';
    doc.Game.TAnswer.value = '';
    doc.Game.TMessage.value = '';
    doc.Game.TPrevious.value = '';
    curWord = Math.floor(Math.random() * word.length);
    doc.Game.TWord.value = FillNewWord(curWord);
}

function FillNewWord(curWord, wpos, letter){
    var blankSpace = '';
    for(var j = 0; j &lt; word[curWord].length; j++){
        blankSpace += "_ ";
    }
    return blankSpace;
}

function DeBlankMachine(curWord, wpos, letter, old){
    var oldArray = ExplodeStringToArray(old);

    for(var i = 0; i &lt; word[curWord].length; i++){
        if(wpos == i){
            oldArray[2*i] = letter;
        }
    }

    return ImplodeArrayToString(oldArray)

}

function ExplodeStringToArray(string){
    var stringLength = string.length;
    var charArray = new Array(stringLength);

    for(var i = 0; i &lt; stringLength; i++){
        charArray[i] = string.charAt(i);
    }

    return charArray;

}

function ImplodeArrayToString(array){
    var newString = '';

    for(var i = 0; i &lt; array.length; i++){
        newString += array[i];
    }

    return newString;
}

function ShowHelp(){
    NewWindow = window.open('help_popup.htm','newWin','width=450,height=350, scrollbars=yes');
}</pre>
<p>And finally weve got to style the thing, style.css</p>
<pre class="brush:css">#container{width:180px; margin-left:auto;margin-right:auto; font-family:tahoma, arial, sans-serif; color:#333;}
#head {font-size:1.2em;}
#head, #body_head, #body_footer {font-weight:bold;}

#head, #body_head, #body_footer {text-align:center;}

#head{}

#body{}
#body_head{}
#body_image{}
#PicHang{border:1px solid #000;}
#body_footer{margin-bottom:5px;}

#response{}
#response{}

#response input#TWord, #response input#TGuess, #response input#TAnswer, #response input#TMessage,#response input#TPrevious {text-align:center; text-transform:uppercase; margin-top:5px; margin-bottom:5px;}
#response input#TWord, #response input#TAnswer, #response input#TMessage,#response input#TPrevious {border:0; border-bottom:1px solid #ccc; font-weight:bold; font-size:12px; color:#000080; width:180px;}
#response input#TGuess {width:15px;}
#response input#TAnswer {font-weight:bold; font-size:14px; color:#800000; width:180px;}
#response label{font-weight:bold;}
#response .action_buttons{width:80px; margin-left:5px; margin-top:5px; cursor:pointer;}
#guess{}
#footer{}</pre>
<p>And thats it, a genuine, working hangman game, with proper string manipulation functions. Give it a go :)</p>
<p><map name='google_ad_map_133_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/133?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_133_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=133&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjavascript%2Fputting-together-a-javascript-hangman-game%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/javascript/putting-together-a-javascript-hangman-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write a simple Bingo Card with Javascript and Jquery</title>
		<link>http://threadbarecanvas.com/jquery/bingo-card-javascript-and-jquery/</link>
		<comments>http://threadbarecanvas.com/jquery/bingo-card-javascript-and-jquery/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 20:07:59 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=122</guid>
		<description><![CDATA[Writing a bingo card couldn&#8217;t be easier with tools such as JQuery and a brain. There are some simple techniques that you need to put into place to get it all up and running. There are three files included in this tutorial. index.html, style.css and script.js
Now, you should end up with something like this:

Source Demo
If [...]]]></description>
			<content:encoded><![CDATA[<p>Writing a bingo card couldn&#8217;t be easier with tools such as JQuery and a brain. There are some simple techniques that you need to put into place to get it all up and running. There are three files included in this tutorial. index.html, style.css and script.js</p>
<p>Now, you should end up with something like this:</p>
<p style="text-align: center;"><img class="aligncenter" style="align-center" src="http://threadbarecanvas.com/wp-content/uploads/2009/10/bingo.png" alt="" width="350px" height="329px" /></p>
<p style="text-align: center; font-size: 24px;"><strong><a title="JQuery Content Slider Source" href="/wp-content/uploads/2009/10/io.zip" target="_blank">Source</a> <a title="Simple Bingo Card" href="/wp-content/uploads/2009/10/index.html" target="_blank">Demo</a></strong></p>
<p>If you want to glance through the source code you can do so here: index.html</p>
<pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset=utf-8 /&gt;
        &lt;title&gt;Bingo - Card&lt;/title&gt;
        &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
        &lt;!--[if IE]&gt;
        &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
    &lt;![endif]--&gt;

        &lt;script type="text/javascript" src="assets/js/script.js"&gt;&lt;/script&gt;
        &lt;link rel="stylesheet" type="text/css" media="screen" href="assets/css/style.css" /&gt;
    &lt;/head&gt;
    &lt;body&gt;

        &lt;div id="page"&gt;
            &lt;h1&gt;Free Bingo Card&lt;/h1&gt;
            &lt;table&gt;
                &lt;tr&gt;
                    &lt;td id="cell0"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell5"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell10"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell14"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell19"&gt;&nbsp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td id="cell1"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell6"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell11"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell15"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell20"&gt;&nbsp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td id="cell2"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell7"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="free"&gt;Free&lt;/td&gt;
                    &lt;td id="cell16"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell21"&gt;&nbsp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td id="cell3"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell8"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell12"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell17"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell22"&gt;&nbsp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
                    &lt;td id="cell4"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell9"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell13"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell18"&gt;&nbsp;nbsp;&lt;/td&gt;
                    &lt;td id="cell23"&gt;&nbsp;nbsp;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
            &lt;h3&gt;&lt;a href="#" id="newCard" &gt;Click me for a new card&lt;/a&gt;&lt;/h3&gt;
        &lt;/div&gt;

    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The following is the source of the CSS: style.css</p>
<pre class="brush:css">
#page{
    width:455px;
    margin:0 auto;
}

td{
    font-family:arial;
    color:#333;
    padding:10px;
    width:50px;
    height:50px;
    text-align:center;
    border:10px solid #ddc;
    background-color:#eee;
}

.bingohead{
    border:10px solid #c2324c;
}

h1, h3, h3 a{
    font-family:arial;
    text-align:center;
    padding:3px;
    color:#211111;
    background-color:#EEEEEE;
    border:2px solid #DDDDCC;
}

td{
    cursor:pointer;
}

#free{
    background-color:#fff;
    color:#eee;
    cursor:default;
}
</pre>
<p>And finally all of that JavaScript goodness: script.js</p>
<pre class="brush:js">
$(document).ready(function(){

    var usedArray = new Array(76);
    var baseArray = new Array(0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4);
    var number = 0;
    var base = 0;

    init();

    function init(){
        for(var i = 0; i<24; i++){
            fillCard(i);
        }
    }

    function fillCard(i){
        base = baseArray[i] * 15;
        number = base + Math.floor(Math.random()*15)+1;

        if(usedArray[number] != true){
            $('#cell'+i).html(number);
            usedArray[number] = true;
        }else{
            fillCard(i);
        }
    }

    function resetUsedNumbersArray(){
        for(var j = 0; j < usedArray.length; j++){
            usedArray[j] = false;
        }
    }

    $('#newCard').click(function(){
        resetUsedNumbersArray();
        init();
    });

    $('td').click(function(){

        var toggle = this.style;
        toggle.backgroundColor = toggle.backgroundColor? "":"#333";
        toggle.color = toggle.color? "":"#fff";
    });

});
</pre>
<p>Something to read while eating your sandwich and drinking your tea, yummie! Extreme programming!!</p>
<p><map name='google_ad_map_122_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/122?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_122_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=122&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjquery%2Fbingo-card-javascript-and-jquery%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/jquery/bingo-card-javascript-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Way Tweet a Java App</title>
		<link>http://threadbarecanvas.com/java/one-way-tweet-a-java-app/</link>
		<comments>http://threadbarecanvas.com/java/one-way-tweet-a-java-app/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 09:33:31 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=115</guid>
		<description><![CDATA[One way tweet is a sending application for twitter. In this tutorial you will see/learn how to send stuff to twitter by writing a java desktop UI. You will create a new project in NetBeans and choose java application, and create a new package called org.me.owt. 
Then, create a new java source file and call it [...]]]></description>
			<content:encoded><![CDATA[<p>One way tweet is a sending application for twitter. In this tutorial you will see/learn how to send stuff to twitter by writing a java desktop UI. You will create a new project in NetBeans and choose java application, and create a new package called org.me.owt. </p>
<p>Then, create a new java source file and call it main.java, and another called tweet.java. Two simple classes and you&#8217;ve got yourself a twitter client. The end result will look like this:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/owt.png"><img src="http://threadbarecanvas.com/wp-content/uploads/2009/07/owt.png" alt="One Way Tweet" title="One Way Tweet" width="309" height="312" class="aligncenter size-full wp-image-116" /></a></p>
<pre class="brush:java">
/*
 * Main.java
 *
 * Created on 23-Jul-2009, 11:57:04
 */
package org.me.owt;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Siriquelle
 */
public class Main extends javax.swing.JFrame {

    private JButton button;

    /** Creates new form Main*/
    public Main() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        usernamelabel = new java.awt.Label();
        username = new java.awt.TextField();
        passwordlabel = new java.awt.Label();
        password = new java.awt.TextField();
        status = new java.awt.TextArea();
        tweet = new java.awt.Button();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("One Way Tweet");
        setBackground(new java.awt.Color(204, 255, 255));
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setForeground(new java.awt.Color(204, 255, 255));
        setName("One Way Tweet"); // NOI18N
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(204, 255, 255));
        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setAlignmentX(getWidth() / 2);
        jPanel1.setAlignmentY(getHeight() / 2);

        usernamelabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        usernamelabel.setForeground(new java.awt.Color(0, 102, 102));
        usernamelabel.setName("usernameLabel"); // NOI18N
        usernamelabel.setText("Username");

        username.setForeground(new java.awt.Color(51, 51, 51));
        username.setName("username"); // NOI18N
        username.addFocusListener(new java.awt.event.FocusAdapter() {

            public void focusGained(java.awt.event.FocusEvent evt) {
                Main.this.focusGained(evt);
            }

            public void focusLost(java.awt.event.FocusEvent evt) {
                Main.this.focusLost(evt);
            }
        });

        passwordlabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        passwordlabel.setForeground(new java.awt.Color(0, 102, 102));
        passwordlabel.setName("passwordLabel"); // NOI18N
        passwordlabel.setText("Password");

        password.setEchoChar('*');
        password.setForeground(new java.awt.Color(51, 51, 51));
        password.setName("password"); // NOI18N
        password.addFocusListener(new java.awt.event.FocusAdapter() {

            public void focusGained(java.awt.event.FocusEvent evt) {
                Main.this.focusGained(evt);
            }

            public void focusLost(java.awt.event.FocusEvent evt) {
                Main.this.focusLost(evt);
            }
        });

        status.setForeground(new java.awt.Color(51, 51, 51));
        status.setName("status"); // NOI18N
        status.addFocusListener(new java.awt.event.FocusAdapter() {

            @Override
            public void focusGained(java.awt.event.FocusEvent evt) {
                Main.this.focusGained(evt);
            }

            @Override
            public void focusLost(java.awt.event.FocusEvent evt) {
                Main.this.focusLost(evt);
            }
        });

        tweet.setActionCommand("tweet");
        tweet.setBackground(new java.awt.Color(153, 255, 255));
        tweet.setFont(new java.awt.Font("Impact", 1, 48)); // NOI18N
        tweet.setForeground(new java.awt.Color(0, 102, 102));
        tweet.setLabel("tweet");
        tweet.setName("tweet"); // NOI18N
        tweet.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tweetMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE).addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(passwordlabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(usernamelabel, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))).addComponent(tweet, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)).addContainerGap()));
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addComponent(usernamelabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(passwordlabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(tweet, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap()));

        usernamelabel.getAccessibleContext().setAccessibleName("usernameLabel");
        username.getAccessibleContext().setAccessibleName("username");
        password.getAccessibleContext().setAccessibleName("password");
        status.getAccessibleContext().setAccessibleName("status");
        tweet.getAccessibleContext().setAccessibleName("tweet");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE));
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE));

        getAccessibleContext().setAccessibleName("One Way Tweet");
        getAccessibleContext().setAccessibleDescription("One Way Tweet");

        pack();
    }// </editor-fold>

    private void tweetMouseClicked(java.awt.event.MouseEvent evt) {
        Tweet tw = new Tweet(username.getText(), password.getText(), status.getText());
        if (tw.sendTweet())
        {
            this.ShowMessageDialog("Tweet Win");
        } else
        {
            this.ShowMessageDialog("Tweet Fail");
        }
    }

    private void focusGained(java.awt.event.FocusEvent evt) {
        evt.getComponent().setBackground(new java.awt.Color(255, 255, 215));
    }

    private void focusLost(java.awt.event.FocusEvent evt) {
        evt.getComponent().setBackground(new java.awt.Color(255, 255, 255));
    }

    public void ShowMessageDialog(String msg) {
        final JFrame frame = new JFrame(msg);
        button = new JButton("OK");
        button.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent evt) {
                frame.dispose();
            }
        });

        JPanel panel = new JPanel();
        panel.add(button);
        panel.add(button);
        frame.add(panel);
        frame.setSize(220, 80);
        frame.setLocation(220, 80);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JPanel jPanel1;
    private java.awt.TextField password;
    private java.awt.Label passwordlabel;
    private java.awt.TextArea status;
    private java.awt.Button tweet;
    private java.awt.TextField username;
    private java.awt.Label usernamelabel;
    // End of variables declaration
}
</pre>
<p>The following code is a class that handles the tweet. create a new java source file in the org.me.owt package and call it tweet.java. It&#8217;s methods are used to create and send the tweet and handle the response from the twitter api:</p>
<pre class="brush:java">
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.me.owt;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

/**
 *
 * @author Siriquelle
 */
public class Tweet {

    private String twitteruser;
    private String twitterpass;
    private String status;
    private String response;

    public Tweet(String u, String p, String s) {
        twitteruser = u;
        twitterpass = p;
        status = s;
    }

    public boolean sendTweet() {
        try
        {
            String encodedData = URLEncoder.encode(status, "UTF-8");

            String credentials = twitteruser + ":" + twitterpass;
            String encodecredentials = new sun.misc.BASE64Encoder().encode(credentials.getBytes());

            URLConnection connection = null;
            URL url = new URL("http://twitter.com/statuses/update.xml");
            connection = url.openConnection();
            connection.setRequestProperty("Authorization", "Basic " + encodecredentials);
            connection.setDoOutput(true);

            OutputStreamWriter output = new OutputStreamWriter(connection.getOutputStream());
            output.write("status=" + encodedData);
            output.close();

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String decodedString;
            while ((decodedString = in.readLine()) != null)
            {
                response = decodedString;
            }
            in.close();
            return true;
        } catch (Exception e)
        {
            response = e.toString();
            return false;
        }
    }
}
</pre>
<p>And thats the code, right click your project and choose run. After you examine this code you&#8217;ll discover how, with a little parsing you can turn this application into a fully fledged thwirl competitor. :) If you&#8217;ve any questions I&#8217;d love a go at answering.</p>
<p>This application was created in netbeans using the swing UI builder. In a future post I will describe the process to building an application using the NetBeans IDE and it&#8217;s UI builders in design view.</p>
<p><map name='google_ad_map_115_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/115?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_115_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=115&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava%2Fone-way-tweet-a-java-app%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java/one-way-tweet-a-java-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Universal Translator for your Tweets</title>
		<link>http://threadbarecanvas.com/java-web/universal-translator-for-your-tweets/</link>
		<comments>http://threadbarecanvas.com/java-web/universal-translator-for-your-tweets/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 10:21:19 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[google translate]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[twitter api]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=98</guid>
		<description><![CDATA[I thought this was going to be easy&#8230; SO much for preconceptions. Today, I&#8217;m going to give you the code to create a twitter translation App using, HTML, CSS, JavaScript and Java, the Twitter API and the Google Translate API. In a future tutorial I will demonstrate cross domain Ajax to get this Application to [...]]]></description>
			<content:encoded><![CDATA[<p>I thought this was going to be easy&#8230; SO much for preconceptions. Today, I&#8217;m going to give you the code to create a twitter translation App using, HTML, CSS, JavaScript and Java, the Twitter API and the Google Translate API. In a future tutorial I will demonstrate cross domain Ajax to get this Application to work totally on the client side but in the mean time you will need to have a Java enabled server to execute the server-side <abbr title="Java Server Page">JSP</abbr> that requests the API for twitter.</p>
<p>As you type your tweet the the JavaScript will analyze your keystrokes and check for when a space is entered assuming you are done typing a word, at this point the text is passed to Google for translation. When your done typing hit tweet and it&#8217;s off to twitter with your tweet.</p>
<p>This is what your app will look like when it&#8217;s finished:</p>
<p><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/translateApp.png"><img class="aligncenter size-full wp-image-99" title="translateApp" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/translateApp.png" alt="translateApp" width="399" height="395" /></a></p>
<p style="text-align: center; font-size: 24px;"><strong><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/twitterLang.zip" target="_blank">Source</a><br />
</strong></p>
<p>The Folder structure you will need is similar to all other projects. You can download the source folder for this project and open it in NetBeans to get a better idea of how the end result will look. There are no special libraries you need to get this going just java.io.* and java.net.* .</p>
<p>This is the HTML you will need, (/index.html):</p>
<pre class="brush:html">&lt;!DOCTYPE html&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;link rel="Stylesheet" media="screen" href="assets/css/style.css" &gt;
        &lt;title&gt;Twitter Universal Translate&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="content"&gt;
            &lt;div class="head"&gt;Twitter Multilanguage&lt;/div&gt;

            &lt;form&gt;
                &lt;label class="textlabel" for="username"&gt;Username&lt;/label&gt;
                &lt;input class="textinput" type="text" id="username" name="username" value=""&gt;

                &lt;label class="textlabel" for="password"&gt;Password&lt;/label&gt;
                &lt;input class="textinput" type="password" id="password" name="password" value=""&gt;

                &lt;label class="textlabel" for="lang"&gt;Translate To&lt;/label&gt;
                &lt;select class="select" id="lang" name="lang" onclick="translateTwo()" &gt;
                    &lt;option value="en"&gt;English&lt;/option&gt;
                    &lt;option value="fr"&gt;French&lt;/option&gt;
                    &lt;option value="it"&gt;Italian&lt;/option&gt;
                    &lt;option value="de"&gt;German&lt;/option&gt;
                &lt;/select&gt;

                &lt;label class="textlabel" for="textarea"&gt;Tweet&lt;/label&gt;
                &lt;textarea id="textarea" class="textarea" name="textarea" cols="5" rows="5" onblur="translateTwo()" onkeydown="translate(event)"&gt;&lt;/textarea&gt;

                &lt;input class="textinput" type="button" value="Tweet" onclick="callLoad()"/&gt;
            &lt;/form&gt;
            &lt;div class="infobar"&gt;“Translate your tweet into a chosen language as you type.”&lt;/div&gt;
            &lt;span id="status"&gt;&lt;/span&gt;
        &lt;/div&gt;

        &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="assets/js/jscript.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>This is the CSS you will need, (/assets/css/style.css):</p>
<pre class="brush:css">* {
    margin: 0;
    padding: 0;
}

/*///////////////////////////////////////////////////*/

#content{
    color:#333;
    width:350px;
    margin:100px auto;
    border:15px inset #66ffff;
    padding:10px;
    font-family:sans-serif;
    -moz-border-radius:10px;
}

.textlabel,textinput{
    display:block;
}

.textlabel{
    font-weight:bold;
}

.textlabel,.textinput, .textarea,.select{
    width:200px;
}

.textinput, .textarea,.select{
    padding:1px;
    margin-bottom:5px;
}

.textinput:focus, .textarea:focus{
    background-color:#ffffcc;
}

.head{
    font-size:32px;
    font-family:sans-serif;
    font-weight:bold;
    margin-bottom:5px;
}

.infobar{
    width:120px;
    float:right;
    position:relative;
    top:-140px;
    left:0px;
    padding: 3px;
    border:5px #ffff99 solid;
    background-color:#ffffcc;
    color:#003333;
    font-size:14px;
    font-style:oblique;
    text-align:center;
}</pre>
<p>This is the JavaScript you will need, (/assets/js/jscript.js):</p>
<pre class="brush:jscript">google.load("language", "1");

function translate(event){
    var textarea = document.getElementById("textarea");
    var lang = document.getElementById("lang");

    if(event.keyCode == 32){
        google.language.translate(textarea.value, "", lang.value, function(result) {
            if (!result.error) {
                var container = document.getElementById("textarea");
                container.value = result.translation + " ";
            }
        });
    }
}

function translateTwo(){
    var textarea = document.getElementById("textarea");
    var lang = document.getElementById("lang");
    google.language.translate(textarea.value, "", lang.value, function(result) {
        if (!result.error) {
            var container = document.getElementById("textarea");
            container.value = result.translation + " ";
        }
    });
}

function load(url, callback) {
    var xhr = new XMLHttpRequest();

    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;
    var status = document.getElementById("textarea").value;
    var auth = "tweet.jsp?username="+username+"&amp;password="+password+"&amp;status="+status;

    xhr.onreadystatechange = function() {
        if((xhr.readyState &lt; 4) || xhr.status !== 200) return;
        callback(xhr);
    };
    try{
        xhr.open('GET', auth, true);
        xhr.send();
    }catch(e){
        document.write(e);
    }
}

function callLoad(){
    load('tweet.jsp', function(xhr) {
        var joke = document.getElementById("status");
        var textarea = document.getElementById("textarea");
        joke.innerHTML = '<strong>OK</strong>';
        textarea.value = '';
    });
}</pre>
<p>This is the Java you will need, (/tweet.jsp):</p>
<pre class="brush:java">&lt;%@page import="java.net.*, java.io.*"%&gt;
&lt;%
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String status = request.getParameter("status");
        try {
            String twitteruser = username;
            String twitterpass = password;
            String encodedData = URLEncoder.encode(status, "UTF-8");

            String credentials = twitteruser + ":" + twitterpass;
            String encodecredentials = new sun.misc.BASE64Encoder().encode(credentials.getBytes());

            URLConnection connection = null;
            URL url = new URL("http://twitter.com/statuses/update.xml");
            connection = url.openConnection();
            connection.setRequestProperty("Authorization", "Basic " + encodecredentials);
            connection.setDoOutput(true);

            OutputStreamWriter output = new OutputStreamWriter(connection.getOutputStream());
            output.write("status=" + encodedData);
            output.close();

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String decodedString;
            while ((decodedString = in.readLine()) != null) {
                out.println(decodedString);
            }
            in.close();

        } catch (Exception e) {
            System.out.println(e.toString());
        }

%&gt;</pre>
<p>Ideally a Servlet would be best suited to processing the response from twitter but for this project it&#8217;s OK. And there you go you can now tweet in multiple languages like James Bond might. yay!</p>
<p><map name='google_ad_map_98_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/98?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_98_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=98&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Funiversal-translator-for-your-tweets%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/universal-translator-for-your-tweets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a JavaWeb Email Contact Form</title>
		<link>http://threadbarecanvas.com/java-web/creating-a-javaweb-email-contact-form/</link>
		<comments>http://threadbarecanvas.com/java-web/creating-a-javaweb-email-contact-form/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 22:29:06 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java Web]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javaMail]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=82</guid>
		<description><![CDATA[In a previous tutorial I have explained how to create a new NetBeans project and add a library to it to make the classes that are available in a jar available to use in your own project. If you are unsure how to do this go ahead and check out this article.
In this tutorial I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous tutorial I have explained how to create a new NetBeans project and add a library to it to make the classes that are available in a <abbr title="Java Archive file">jar</abbr> available to use in your own project. If you are unsure how to do this go ahead and check out <a href="http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/">this article</a>.</p>
<p style="text-align: left;">In this tutorial I&#8217;m going to explain how to create a contact form with a jQuery validation template for you to play with that will send an email to whomever. The end result should look like this:</p>
<p style="text-align: center;"><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/form.png"><img class="size-full wp-image-85 aligncenter" title="form" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/form.png" alt="form" width="503" height="397" /></a></p>
<p style="text-align: center; font-size: 24px;"><strong><a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/Contactform.zip" target="_blank">Source</a><br />
</strong></p>
<p>Your going to need some form of access to an smtp mailbox with a username and password. You can use your gmail account info if you like, all your going to need is your gmail address and password.<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/gmail.png"><img class="alignnone size-full wp-image-86" title="gmail" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/gmail.png" alt="gmail" width="551" height="167" /></a></p>
<p>Now for the fun part, First of all you need to set up a new web application project in netBeans I&#8217;ve called mine ContactForm. In the index.jsp file in the root of your directory you should past this html structure. It&#8217;s going to set up the form. Simple elegant yet expandable if you want. You&#8217;ll see how easy it is to build custom emails with this form by adding new fields and manipulating a variable or two near the end of this tutorial.</p>
<pre class="brush:html">&lt;%@page import="mail.SendEmail" %&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" &gt;
        &lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css"&gt;
        &lt;link href="assets/css/style.css" rel="stylesheet" type="text/css" media="screen" &gt;
        &lt;title&gt;Multilingual Contact Form&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="container"&gt;
            &lt;p class="heading"&gt;Contact Form&lt;/p&gt;
            &lt;form action="index.jsp" method="POST"&gt;
                &lt;div class="input"&gt;
                    &lt;label for="fullname"&gt;Name:&lt;/label&gt;
                    &lt;input type="text" id="fullname" name="fullname" value="" /&gt;
                    &lt;div id="fullname_warn" &gt;&lt;/div&gt;
                &lt;/div&gt;

                &lt;div class="input"&gt;
                    &lt;label for="email" &gt;Email:&lt;/label&gt;
                    &lt;input type="text" id="email" name="email" value="" /&gt;
                    &lt;span id="email_warn" &gt;&lt;/span&gt;
                &lt;/div&gt;

                &lt;div class="input"&gt;
                    &lt;label for="message" &gt;Message:&lt;/label&gt;
                    &lt;textarea cols="10" rows="5" id="message" name="message"&gt;&lt;/textarea&gt;
                &lt;/div&gt;

                &lt;input type="submit" name="send" value="send" id="send" /&gt;
            &lt;/form&gt;

            &lt;%
        if (request.getParameter("fullname") != null) {
            String fullname = request.getParameter("fullname");
            String email = request.getParameter("email");
            String message = request.getParameter("message");

            if (mail.SendEmail.run(email, fullname, message)) {
            %&gt;
            &lt;p class="goodtogo end"&gt;Mail Sent Successfully&lt;/p&gt;
            &lt;%} else {%&gt;
            &lt;p class="warning end"&gt;Error Sending Mail&lt;/p&gt;
            &lt;%}
        }
            %&gt;

        &lt;/div&gt;
        &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
        &lt;script type="text/javascript" src="assets/js/jscript.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Now that the html structure is in place it&#8217;s time to transform it into something a little easier on the eye. We&#8217;re going to add some styles. Before you go ahead and do this you should go ahead and set up your folder structures. It&#8217;s imperative that you have your files arranged in an organized way so that other developers can easily find what their looking. That, and if you need to take pictures to remember a holiday then you should defiantly be making your documents easier to find. Your folder structure should look like this:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/folderstructure.png"><img class="alignnone size-full wp-image-87" title="folderstructure" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/folderstructure.png" alt="folderstructure" width="214" height="487" /></a></p>
<p>Now that youve got somewhere to put your styles you should go ahead and stick them in this folder. Here they are:</p>
<pre class="brush:css">div#container{
    max-width:578px;
    min-width:440px;
    border:1px solid #222;
    padding:20px;
    margin:100px auto;
    color:#222233;
    font-family:sans-serif;
    -moz-border-radius:20px;
}

p.heading{
    font-size:36px;
    font-weight:bold;
}

.input,#send{
    font-size:24px;
    margin-top:10px;
}

.input label{
    display:block;
    text-decoration:underline;
}

.input input, .input textarea{
    width:300px;
    padding:1px;
}

#send{
    font-size:16px;
    cursor:pointer;
    width:120px;
    height:50px;
}

.warning, .goodtogo{
    font-size:20px;
    padding-left:35px;
    width:225px;
    height:33px;
    float:right;
    clear:right;

}

.warning{
    background:transparent url(../img/warn.png) no-repeat -5px -33px scroll;
}

.goodtogo{
    background:transparent url(../img/warn.png) no-repeat 0px 0px scroll;
}

.end{
    position:relative;
    top:-40px;
}</pre>
<p>Now you need a sprite for your error icons. I&#8217;ve made this one you should stick it in the &#8216;img&#8217; folder your created under &#8216;assets&#8217; like the structure shown above.<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/warn.png"><img class="alignnone size-full wp-image-84" title="warn" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/warn.png" alt="warn" width="40" height="60" /></a></p>
<p>The following demonstrates dynamic class application with JQuery. You should play around with this fill and add validation to the form fields while getting familiar with the JQuery framework:</p>
<pre class="brush:jscript">$(document).ready(function() {

    var fullname = $('#fullname');
    var fullname_warn = $('#fullname_warn');

    var email = $('#email');
    var email_warn = $('#email_warn');

    fullname.focus(function(){
        fullname_warn.removeClass('goodtogo');
        fullname_warn.addClass('warning');
        fullname_warn.html("Cannot be blank");

        fullname.blur(function(){
            fullname_warn.removeClass('warning');
            fullname_warn.addClass('goodtogo');
            fullname_warn.html(" ");
        });
    });

    email.focus(function(){
        email_warn.removeClass('goodtogo');
        email_warn.addClass('warning');
        email_warn.html("Cannot be blank");

        email.blur(function(){
            email_warn.removeClass('warning');
            email_warn.addClass('goodtogo');
            email_warn.html(" ");
        });
    });

});</pre>
<p>Now that we have a base structure in place it&#8217;s time to start bringing in the JavaMail API into your project. Ive made it available to <a href="http://files.getdropbox.com/u/414996/mail.jar">download here</a> so you can just download it. Ok? Create a JavaMail library and add it to your project as in the<a href="http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/"> iText tutorial.</a></p>
<p>So the final step in this is easy&#8230; Create a new package called &#8216;mail&#8217; in your Source Packages roll out in your project folder structure as seen here:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/javaClassStructure.png"><img class="alignnone size-full wp-image-88" title="javaClassStructure" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/javaClassStructure.png" alt="javaClassStructure" width="214" height="55" /></a></p>
<p>As you can see from above a new Java Class file called SendMail has been added to the &#8216;mail&#8217; package, create that file now and add this code to it:</p>
<pre class="brush:java">package mail;

/**
 *
 * @author Siriquelle
 */
import java.util.Date;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

/**
 *
 * @author Siriquelle
 */
public class SendEmail {

    public static boolean run(String addressedTo, String subject, String content) {

        String fromAddress = "Your Name ";//Your Email Address//
        String recipients = addressedTo.trim();
        String contentType = "text/plain";

        String smtpHost = "smtp.gmail.com";//Your Outgoing Mailbox//
        int smtpPort = 587;
        String username = "you@gmail.com";//Your Mailbox Username//
        String password = "yourpassword";//Your Mailbox Password//

        try
        {
            Properties props = System.getProperties();
            props.put("mail.smtp.starttls.enable", "true");
            Session session = Session.getDefaultInstance(props);

            MimeMessage message = new MimeMessage(session);

            message.setFrom(new InternetAddress(fromAddress));
            message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(recipients, false));

            message.setSubject(subject);
            message.setContent(content, contentType);
            message.setSentDate(new Date());

            Transport transport = session.getTransport("smtp");
            transport.connect(smtpHost, smtpPort, username, password);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();

            return true;
        } catch (MessagingException messagingException)
        {
            System.out.print(messagingException);
            return false;

        } catch (Exception e)
        {
            System.out.print(e);
            return false;
        }
    }
}</pre>
<p>And that is it. You should now have a valid working form that will send emails. Nice. If you don&#8217;t check that your folder structure matches <a title="Folder Structure" href="http://threadbarecanvas.com/wp-content/uploads/2009/07/folderstructure.png" target="_blank">mine</a>. Check that you&#8217;ve added your own GMail username and password in the SendEmail java class.</p>
<p><map name='google_ad_map_82_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/82?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_82_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=82&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava-web%2Fcreating-a-javaweb-email-contact-form%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java-web/creating-a-javaweb-email-contact-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Content Slider with JQuery</title>
		<link>http://threadbarecanvas.com/jquery/creating-a-content-slider-with-jquery/</link>
		<comments>http://threadbarecanvas.com/jquery/creating-a-content-slider-with-jquery/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 14:36:37 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=64</guid>
		<description><![CDATA[Content sliders add very nice interactivity to your website. In this tutorial I will show you how to use jQuery to create a simple content slider. Of course you can change the styles look and feel of the product your self but for now I&#8217;m keeping it simple. The final product will look like this:

Source [...]]]></description>
			<content:encoded><![CDATA[<p>Content sliders add very nice interactivity to your website. In this tutorial I will show you how to use jQuery to create a simple content slider. Of course you can change the styles look and feel of the product your self but for now I&#8217;m keeping it simple. The final product will look like this:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/JQuery-Slider.png"><img class="aligncenter size-full wp-image-66" title="JQuery Content Slider" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/JQuery-Slider.png" alt="JQuery Content Slider" width="498" height="160" /></a></p>
<p style="text-align: center;font-size:24px"><strong><a title="JQuery Content Slider Source" href="/wp-content/uploads/2009/07/io.zip" target="_blank">Source</a> <a title="JQuery Content Slider Demo" href="/wp-content/uploads/2009/07/io/index.html" target="_blank">Demo</a></strong></p>
<p>First thing you should do is get your folder structure in order so in the root folder of your project create a folder called &#8216;assets&#8217; and in that folder create three more folders called &#8216;js&#8217;, &#8217;style&#8217; and &#8216;img&#8217; to contain your JavaScript your <abbr title="Cascading Style Sheet">css</abbr> and your images. I am using &#8216;io&#8217; as my root folder but you can use whatever you like, somehting liek &#8216;Content_Slider&#8217; comes to mind. The end folder structure should will look like this:<br />
<a href="http://threadbarecanvas.com/wp-content/uploads/2009/07/Folder-Structure.png"><img class="alignnone size-full wp-image-65" title="Folder Structure" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/Folder-Structure.png" alt="Folder Structure" width="114" height="84" /></a></p>
<p>In the project root folder create a new <abbr title="Hyper-Text Markup Language">html</abbr> file and name it index.html and past the following code inside:</p>
<pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
    &lt;link href="assets/css/style.css" media="screen" type="text/css" rel="stylesheet" /&gt;
    &lt;title&gt;JQuery Content Slider&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="content"&gt;
      &lt;div id="leftArrow"&gt;&lt;/div&gt;
      &lt;div id="viewport"&gt;
        &lt;div id="conveyor"&gt;
          &lt;div class="item no1"&gt;
            &lt;p&gt;Hello&lt;/p&gt;
            &lt;div class="news no3"&gt;
              &lt;p&gt;Hello&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="item no2"&gt;
            &lt;p&gt;Hello&lt;/p&gt;
            &lt;div class="news no1"&gt;
              &lt;p&gt;Hello&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="item lastItem no3"&gt;
            &lt;p&gt;Hello&lt;/p&gt;
            &lt;div class="news no2"&gt;
              &lt;p&gt;Hello&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="rightArrow"&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript"
    src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="assets/js/JavaScript.js"&gt;
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now that the html file is set up you&#8217;ll need to create another file called style.css to contain all of your styles. Copy and past this code into the style.css file and stick it into the css folder:</p>
<pre class="brush:css">
* {
    margin: 0;
    padding: 0;

}
body {
    font: 71%/1.5 Verdana, Sans-Serif;
    background: #eee;

}

/* */
#content{
    margin:100px auto;
    padding:5px;
    width:688px;
    display:table;
}

/* */
#leftArrow, #rightArrow, #viewport{
    float:left;
}
#leftArrow, #rightArrow{
    width:100px;
    height:100px;
    margin:50px auto;
    cursor:pointer;
}
#leftArrow{
    background:transparent url(../img/nav.png) no-repeat 0px 0px;
}

#rightArrow{
    clear:right;
    background:transparent url(../img/nav.png) no-repeat 0px -100px;
}

/* */
#viewport{
    width:482px;
    height:200px;
    overflow:hidden;
    border:1px #333 solid;
}

/* */
#conveyor{
    position:relative;
    left:0px;
    width:1452px;
    height:200px;
}

#conveyor .item{
    float:left;
    width:482px;
    height:200px;
}

#conveyor .item .lastItem{
    clear:right;
}

/**/
.news{
    min-height:60px;
    width:476px;
    margin:3px auto;
    position:relative;
    top:100%;
    border:1px #444 solid;
}
/* */
.no1{background-color:aqua;}
.no2{background-color:blue;}
.no3{background-color:green;}

.item, .news, #viewport{
    -moz-border-radius:10px;
}

p{
    padding:15px;
    font-size:24px;
    font-weight:bold;
}
</pre>
<p>Now you should have a page with a look but no interactivity to it so create a new javascript file and call is JavaScript.js and copy and past the following code into it and stick it into your js folder:</p>
<pre class="brush:javascript ">$(document).ready(function() {

    /* */
    var conveyor = $("#conveyor");
    var conveyorPos = conveyor.position();

    var leftArrow = $("#leftArrow");
    var rightArrow = $("#rightArrow");

    var item = $(".item");
    var dist = item.width();

    /* */
    leftArrow.click(function(){
        updateConveyorPos();
        if(conveyorPos.left &lt; 0){             conveyor.animate({                 "left": "+="+dist+"px"             }, "slow");         }     });     rightArrow.click(function(){         updateConveyorPos();         if(conveyorPos.left &gt; -567){
            conveyor.animate({
                "left": "-="+dist+"px"
            }, "slow");
        }
    });

    /* */
    item.mouseenter(function(){
        $(".news").animate({
            "top": "61px"
        }, "slow");

    });

    item.mouseleave(function(){
        $(".news").animate({
            "top": "100%"
        }, "slow");

    });

    /* */
    function updateConveyorPos(){
        conveyorPos = conveyor.position();
        //alert("left: " + conveyorPos.left + "/ dist: " + dist);
    }
});</pre>
<p>Luckily the folks at JQuery offer free hosting for their latest release so we don&#8217;t need to store it in our own file system. But that&#8217;s it, you should now have a JQuery content slider that you can play with yippiee!!.</p>
<p><map name='google_ad_map_64_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/64?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_64_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=64&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjquery%2Fcreating-a-content-slider-with-jquery%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/jquery/creating-a-content-slider-with-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating a PDF Programmatically with iText</title>
		<link>http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/</link>
		<comments>http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 17:00:29 +0000</pubDate>
		<dc:creator>Siriquelle</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://threadbarecanvas.com/?p=48</guid>
		<description><![CDATA[All will agree that pdf&#8217;s are cool, right? So, In this brief tutorial I will be describing how to create a pdf programmaticallywith NetBeans and how to add the iText library to your NetBeans projects. As is always the case this tutorial is intended to wet your appetite for the iText library. When you get [...]]]></description>
			<content:encoded><![CDATA[<p>All will agree that pdf&#8217;s are cool, right? So, In this brief tutorial I will be describing how to create a pdf programmaticallywith NetBeans and how to add the iText library to your NetBeans projects. As is always the case this tutorial is intended to wet your appetite for the iText library. When you get serious you&#8217;ll want to create shapes and play with colors. In this tutorial I will show you how to create a pdf that shows a big Hello World at the top and draws eight squares underneath it. Here is the finished product, you can play around with the collors and draw loop to add more effects.</p>
<p>First thing you will need to have a copy of <a href="http://netbeans.org" target="_blank">NetBeans</a>. And also a copy of the <a href="http://www.lowagie.com/iText/download.html" target="_blank">iText Core</a> jar. In Netbeans you will want to create a new project, call it &#8220;HelloWorld&#8221;. A this point you should create a new package, call it &#8220;pdfbuilder&#8221;.</p>
<p>Right click the package pdfbuilder you&#8217;ve just created and select New &gt; Java Class:</p>
<p><img class="alignnone size-full wp-image-54" title="Creating a New Java Source File" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/41.png" alt="Creating a New Java Source File" width="495" height="88" /></p>
<p>You will need to give the class a name so for this example you should call it HelloWorld then hit finish:</p>
<p><img class="alignnone size-full wp-image-55" title="Naming a Java Class" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/5.png" alt="Naming a Java Class" width="514" height="74" /></p>
<p>Before we continue with the fun part we need to create a library for our iText <abbr title="Java ARchive">jar</abbr> and add it to the project. To do this all you have to do is Right Click on the libraries icon and select Add Library:</p>
<p><img class="alignnone size-full wp-image-49" title="Adding a Library to the project" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/11.png" alt="Adding a Library to the project" width="238" height="200" /></p>
<p>Create a new Library and name it iText:</p>
<p><img class="alignnone size-full wp-image-50" title="Creating the iText Library" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/21.png" alt="Creating the iText Library" width="372" height="200" /></p>
<p>Add the <a href="http://www.lowagie.com/iText/download.html" target="_blank">iText Core jar</a> that was downloaded earlier:</p>
<p><a title="Open Large Image" href="http://threadbarecanvas.com/wp-content/uploads/2009/07/31.png" target="_blank"><img class="alignnone size-full wp-image-51" title="Adding the Jar to the Library" src="http://threadbarecanvas.com/wp-content/uploads/2009/07/31.png" alt="Adding the Jar to the Library" width="537" height="281" /></a></p>
<p>Now your HelloWorld.java is ready to accept the following code:</p>
<pre class="brush:java">package pdfbuilder;

import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfWriter;

public class HelloWorld {

    public static void main(String[] args) {
        try
        {
            //
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/world.pdf"));
            document.open();

            //
            PdfContentByte cb = writer.getDirectContent();
            cb.beginText();
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
                    BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.setFontAndSize(bf, 39);
            cb.setRGBColorFill(0xcc, 0x66, 0x66);
            cb.showTextAligned(Element.ALIGN_LEFT, "Hello World :)", 36, 788, 0);
            cb.endText();

            //
            cb.setRGBColorFill(0x9a, 0xe4, 0xe8);
            for (int i = 0, j = 55; i &lt; (j * 8); i += j)
            {
                cb.roundRectangle(36 + i, 718, 50, 50, 5);
            }
            cb.eoFill();

            //
            document.close();
        } catch (Exception e)
        {
            System.out.println(e);
        }
    }
}</pre>
<p>What you get after you run this program is a file named <a title="Hello World Example" href="http://threadbarecanvas.com/wp-content/uploads/2009/07/world.pdf" target="_blank">world.pdf</a> in the root of your c:/ drive.</p>
<p><map name='google_ad_map_48_d0b0fa17a4b5b092'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/48?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_48_d0b0fa17a4b5b092' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=48&amp;url= http%3A%2F%2Fthreadbarecanvas.com%2Fjava%2Fcreating-a-pdf-programmatically-with-itext%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://threadbarecanvas.com/java/creating-a-pdf-programmatically-with-itext/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
