<?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>Software Passion &#187; Code Snippets</title>
	<atom:link href="http://www.softwarepassion.com/category/code_snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.softwarepassion.com</link>
	<description>by Krzysztof Grajek</description>
	<lastBuildDate>Thu, 18 Mar 2010 17:46:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Android Series: GET, POST and Multipart POST requests</title>
		<link>http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests/</link>
		<comments>http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 08:59:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=389</guid>
		<description><![CDATA[Today I will describe shortly how to execute http GET and POST request on Android platform.
The code is very simple and straightforward, for post request with attachement, you would have to add apache-mime4j-0.6.jar and httpmime-4.0.1.jar to your build path.
HTTP GET




try &#123;
&#160; &#160; &#160; &#160; HttpClient client = new DefaultHttpClient&#40;&#41;; &#160;
&#160; &#160; &#160; &#160; String getURL [...]]]></description>
			<content:encoded><![CDATA[<p>Today I will describe shortly how to execute http GET and POST request on Android platform.<br />
The code is very simple and straightforward, for post request with attachement, you would have to add apache-mime4j-0.6.jar and httpmime-4.0.1.jar to your build path.</p>
<p><strong>HTTP GET</strong><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">try</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpClient client <span class="sy0">=</span> <span class="kw1">new</span> DefaultHttpClient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getURL <span class="sy0">=</span> <span class="st0">&quot;http://www.google.com&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpGet get <span class="sy0">=</span> <span class="kw1">new</span> HttpGet<span class="br0">&#40;</span>getURL<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpResponse responseGet <span class="sy0">=</span> client.<span class="me1">execute</span><span class="br0">&#40;</span>get<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpEntity resEntityGet <span class="sy0">=</span> responseGet.<span class="me1">getEntity</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>resEntityGet <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//do something with the response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;GET RESPONSE&quot;</span>,EntityUtils.<span class="me1">toString</span><span class="br0">&#40;</span>resEntityGet<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p><strong>HTTP POST</strong><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">try</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpClient client <span class="sy0">=</span> <span class="kw1">new</span> DefaultHttpClient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> postURL <span class="sy0">=</span> <span class="st0">&quot;http://somepostaddress.com&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpPost post <span class="sy0">=</span> <span class="kw1">new</span> HttpPost<span class="br0">&#40;</span>postURL<span class="br0">&#41;</span><span class="sy0">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span class="sy0">&lt;</span>NameValuePair<span class="sy0">&gt;</span> params <span class="sy0">=</span> <span class="kw1">new</span> ArrayList<span class="sy0">&lt;</span>NameValuePair<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw1">new</span> BasicNameValuePair<span class="br0">&#40;</span><span class="st0">&quot;user&quot;</span>, <span class="st0">&quot;kris&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw1">new</span> BasicNameValuePair<span class="br0">&#40;</span><span class="st0">&quot;pass&quot;</span>, <span class="st0">&quot;xyz&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UrlEncodedFormEntity ent <span class="sy0">=</span> <span class="kw1">new</span> UrlEncodedFormEntity<span class="br0">&#40;</span>params,HTTP.<span class="me1">UTF_8</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; post.<span class="me1">setEntity</span><span class="br0">&#40;</span>ent<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpResponse responsePOST <span class="sy0">=</span> client.<span class="me1">execute</span><span class="br0">&#40;</span>post<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpEntity resEntity <span class="sy0">=</span> responsePOST.<span class="me1">getEntity</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>resEntity <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;RESPONSE&quot;</span>,EntityUtils.<span class="me1">toString</span><span class="br0">&#40;</span>resEntity<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></div>
<p><strong>HTTP POST with File attachment</strong><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">File</span></a> file <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">File</span></a><span class="br0">&#40;</span><span class="st0">&quot;path/to/your/file.txt&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">try</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpClient client <span class="sy0">=</span> <span class="kw1">new</span> DefaultHttpClient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> postURL <span class="sy0">=</span> <span class="st0">&quot;http://someposturl.com&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpPost post <span class="sy0">=</span> <span class="kw1">new</span> HttpPost<span class="br0">&#40;</span>postURL<span class="br0">&#41;</span><span class="sy0">;</span> <br />
&nbsp; &nbsp; &nbsp;FileBody bin <span class="sy0">=</span> <span class="kw1">new</span> FileBody<span class="br0">&#40;</span>file<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;MultipartEntity reqEntity <span class="sy0">=</span> <span class="kw1">new</span> MultipartEntity<span class="br0">&#40;</span>HttpMultipartMode.<span class="me1">BROWSER_COMPATIBLE</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp;reqEntity.<span class="me1">addPart</span><span class="br0">&#40;</span><span class="st0">&quot;myFile&quot;</span>, bin<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;post.<span class="me1">setEntity</span><span class="br0">&#40;</span>reqEntity<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp;HttpResponse response <span class="sy0">=</span> client.<span class="me1">execute</span><span class="br0">&#40;</span>post<span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp;HttpEntity resEntity <span class="sy0">=</span> response.<span class="me1">getEntity</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>resEntity <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;RESPONSE&quot;</span>,EntityUtils.<span class="me1">toString</span><span class="br0">&#40;</span>resEntity<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Android Series: Using GPS data</title>
		<link>http://www.softwarepassion.com/android-series-using-gps-data/</link>
		<comments>http://www.softwarepassion.com/android-series-using-gps-data/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 12:26:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=386</guid>
		<description><![CDATA[In this tutorial i will show you how to quickly get the gps data using your android device version 1.6+.
All you have to do is to implement one interface and acquire LocationMangager from the adnroid system service.
public class LocationExampleAct extends Activity implements LocationListener&#123;


&#160; &#160; private double latitude;
&#160; &#160; private double longitude;
&#160; &#160; private LocationManager locMgr [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial i will show you how to quickly get the gps data using your android device version 1.6+.</p>
<p>All you have to do is to implement one interface and acquire LocationMangager from the adnroid system service.</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw1">class</span> LocationExampleAct <span class="kw1">extends</span> Activity <span class="kw1">implements</span> LocationListener<span class="br0">&#123;</span><br />
<br />
<br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw4">double</span> latitude<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw4">double</span> longitude<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> LocationManager locMgr <span class="sy0">=</span> <span class="kw2">null</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co3">/** Called when the activity is first created. */</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> onCreate<span class="br0">&#40;</span>Bundle savedInstanceState<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">super</span>.<span class="me1">onCreate</span><span class="br0">&#40;</span>savedInstanceState<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setContentView<span class="br0">&#40;</span>R.<span class="me1">layout</span>.<span class="me1">main</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; locationTxt <span class="sy0">=</span> <span class="br0">&#40;</span>TextView<span class="br0">&#41;</span>findViewById<span class="br0">&#40;</span>R.<span class="me1">id</span>.<span class="me1">location_id</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; locMgr <span class="sy0">=</span> <span class="br0">&#40;</span>LocationManager<span class="br0">&#41;</span><span class="kw1">this</span>.<span class="me1">getSystemService</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Context</span></a>.<span class="me1">LOCATION_SERVICE</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; locMgr.<span class="me1">requestLocationUpdates</span><span class="br0">&#40;</span>LocationManager.<span class="me1">GPS_PROVIDER</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="kw1">this</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> onLocationChanged<span class="br0">&#40;</span>Location location<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">latitude</span> <span class="sy0">=</span> location.<span class="me1">getLatitude</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">longitude</span> <span class="sy0">=</span> location.<span class="me1">getLongitude</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">locationTxt</span>.<span class="me1">setText</span><span class="br0">&#40;</span><span class="st0">&quot;Location: &quot;</span><span class="sy0">+</span><span class="kw1">this</span>.<span class="me1">latitude</span> <span class="sy0">+</span><span class="st0">&quot; : &quot;</span> <span class="sy0">+</span> <span class="kw1">this</span>.<span class="me1">longitude</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;Location change&quot;</span>,<span class="st0">&quot;&quot;</span><span class="sy0">+</span>latitude<span class="sy0">+</span> <span class="st0">&quot; : &quot;</span><span class="sy0">+</span>longitude<span class="br0">&#41;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> onProviderDisabled<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> provider<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> onProviderEnabled<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> provider<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> onStatusChanged<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> provider, <span class="kw4">int</span> status, Bundle extras<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/android-series-using-gps-data/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android Series: Parsing JSON data with GSON</title>
		<link>http://www.softwarepassion.com/android-series-parsing-json-data-with-gson/</link>
		<comments>http://www.softwarepassion.com/android-series-parsing-json-data-with-gson/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 11:56:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Mobile Development]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=377</guid>
		<description><![CDATA[Today I will describe how to parse json data using Gson open source library and how to convert it at the same time to java objects.
This is a typical cookbook example and should be very easy to follow.




1. Create an Android application with one activity, name it as you wish, if you are doing it [...]]]></description>
			<content:encoded><![CDATA[<p>Today I will describe how to parse json data using Gson open source library and how to convert it at the same time to java objects.<br />
This is a typical cookbook example and should be very easy to follow.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
1. Create an Android application with one activity, name it as you wish, if you are doing it in eclipse all the basic stuff will be generated for you which is exactly what we need.<br />
2. Find an example url which  responds in JSON, I have used Twitter Trends found here: <a href="http://search.twitter.com/trends.json">http://search.twitter.com/trends.json</a><br />
The example response looks like this:</p>
<div class="codecolorer-container html4strict " style="overflow:auto;white-space:nowrap;width:535px"><div class="html4strict codecolorer" style="font-family:Monaco,Lucida Console,monospace">{&quot;as_of&quot;:&quot;Thu, 25 Feb 2010 11:30:17 +0000&quot;,&quot;trends&quot;:[{&quot;name&quot;:&quot;#nowplaying&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%23nowplaying&quot;},{&quot;name&quot;:&quot;#nothingworsethan&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%23nothingworsethan&quot;},{&quot;name&quot;:&quot;Dubai Mall&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%22Dubai+Mall%22&quot;},{&quot;name&quot;:&quot;iPad Gets&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%22iPad+Gets%22&quot;},{&quot;name&quot;:&quot;#SuperJuniorTrot&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%23SuperJuniorTrot&quot;},{&quot;name&quot;:&quot;Justin Bieber&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%22Justin+Bieber%22&quot;},{&quot;name&quot;:&quot;Click&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=Click&quot;},{&quot;name&quot;:&quot;Jaebum&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=Jaebum&quot;},{&quot;name&quot;:&quot;#tosavemoney&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=%23tosavemoney&quot;},{&quot;name&quot;:&quot;Protection&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=Protection&quot;}]}</div></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
As you can see this json data contains date attribute called &#8216;as_of&#8217; as well as array of items, each consisting of name and url attributes.<br />
We will create two simple java classes wich will hold that information.<br />
First one is TwitterTrends.java</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">package</span> <span class="co2">com.softwarepassion.jsonexample</span><span class="sy0">;</span><br />
<br />
<span class="kw1">import</span> <span class="co2">java.util.Date</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.util.List</span><span class="sy0">;</span><br />
<br />
<span class="kw1">public</span> <span class="kw1">class</span> TwitterTrends <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> as_of<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> List<span class="sy0">&lt;</span>TwitterTrend<span class="sy0">&gt;</span> trends<span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getAs_of<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> as_of<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> setAs_of<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> asOf<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; as_of <span class="sy0">=</span> asOf<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> List<span class="sy0">&lt;</span>TwitterTrend<span class="sy0">&gt;</span> getTrends<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> trends<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> setTrends<span class="br0">&#40;</span>List<span class="sy0">&lt;</span>TwitterTrend<span class="sy0">&gt;</span> trends<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">trends</span> <span class="sy0">=</span> trends<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></div></div>
<p>And the second one is a simple TwitterTrend.java</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">package</span> <span class="co2">com.softwarepassion.jsonexample</span><span class="sy0">;</span><br />
<br />
<span class="kw1">public</span> <span class="kw1">class</span> TwitterTrend <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> name<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> url<span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getName<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> name<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> setName<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> name<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">name</span> <span class="sy0">=</span> name<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> getUrl<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> url<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> setUrl<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> url<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">url</span> <span class="sy0">=</span> url<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p>TwitterTrends contains a list of TwitterTrend objects, both of them are simple beans and are very similar to the json response if you look closely <img src='http://www.softwarepassion.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Now the fun part begins.</p>
<p>Download the Gson library from <a href="http://code.google.com/p/google-gson/">http://code.google.com/p/google-gson/</a> and add it to your java build path in eclipse.<br />
Once you do that, you can now transform your json response to Java object on Android Platform:<br />
Get the response as InputStream:<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStream</span></a> getJSONData<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> url<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DefaultHttpClient httpClient <span class="sy0">=</span> <span class="kw1">new</span> DefaultHttpClient<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; URI uri<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStream</span></a> data <span class="sy0">=</span> <span class="kw2">null</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uri <span class="sy0">=</span> <span class="kw1">new</span> URI<span class="br0">&#40;</span>url<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpGet method <span class="sy0">=</span> <span class="kw1">new</span> HttpGet<span class="br0">&#40;</span>uri<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpResponse response <span class="sy0">=</span> httpClient.<span class="me1">execute</span><span class="br0">&#40;</span>method<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data <span class="sy0">=</span> response.<span class="me1">getEntity</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getContent</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> data<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></div>
<p>Then use that input stream to create your java objects:</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw4">void</span> runJSONParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;MY INFO&quot;</span>, <span class="st0">&quot;Json Parser started..&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Gson gson <span class="sy0">=</span> <span class="kw1">new</span> Gson<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Areader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Reader</span></a> r <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStreamReader</span></a><span class="br0">&#40;</span>getJSONData<span class="br0">&#40;</span><span class="st0">&quot;http://search.twitter.com/trends.json&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;MY INFO&quot;</span>, r.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; TwitterTrends objs <span class="sy0">=</span> gson.<span class="me1">fromJson</span><span class="br0">&#40;</span>r, TwitterTrends.<span class="kw1">class</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;MY INFO&quot;</span>, <span class="st0">&quot;&quot;</span><span class="sy0">+</span>objs.<span class="me1">getTrends</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span><span class="br0">&#40;</span>TwitterTrend tr <span class="sy0">:</span> objs.<span class="me1">getTrends</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span class="me1">i</span><span class="br0">&#40;</span><span class="st0">&quot;TRENDS&quot;</span>, tr.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot; - &quot;</span> <span class="sy0">+</span> tr.<span class="me1">getUrl</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw1">catch</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> ex<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ex.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></div>
<p>Easy ha!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/android-series-parsing-json-data-with-gson/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Getting started with Apache Click and Eclipse Galileo</title>
		<link>http://www.softwarepassion.com/getting-started-with-apache-click-and-eclipse-galileo/</link>
		<comments>http://www.softwarepassion.com/getting-started-with-apache-click-and-eclipse-galileo/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 10:42:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[apache click]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=356</guid>
		<description><![CDATA[Last couple of days I read here and there about Apache Click, which is now in version 2.1.0. It looks preety cool and easy to learn, so I decided to give it a try and see for myself.
I understand that its cool to learn things using vi and shell only, but when you tried many [...]]]></description>
			<content:encoded><![CDATA[<p>Last couple of days I read here and there about Apache Click, which is now in version 2.1.0. It looks preety cool and easy to learn, so I decided to give it a try and see for myself.<br />
I understand that its cool to learn things using vi and shell only, but when you tried many frameworks before, you know how things works, you just want to see how or how not, productive you can be with the new framework, thats why I jump straight to the IDE.<br />
And here, first surprise, with apache click its&#8217; not that easy, well, I&#8217;m mean its still easy but I have encountered a few problems, and right now I would like to share the solution.<br />
First of all, I did not tried all the examples in the apache click user guide yet, haven&#8217;t build anything usefull and definietly I&#8217;m not an Apache Click expert, I think I have figured out how to plug it to Eclipse and I think this is good start <img src='http://www.softwarepassion.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Here you have a few points to build your Apache Click IDE:<br />
1. First of all download latest and greatest Eclipse Galileo from <a href="http://www.eclipse.org/downloads/">here</a> &#8211; choose Eclipse for Java EE developers<br />
2. Download Apache Click libraries from <a href="http://click.apache.org/">here</a> &#8211; choose version 2.1.0<br />
3. Download Apache Click IDE from <a href="http://click.apache.org/docs/click-ide-downloads.html">here</a> &#8211; note that it contains Click version 1.5 and it was last updated in November 2008 &#8211; maybe I&#8217;m missing something here?<br />
4. Unzip your ClickIDE and copy the &#8216;features&#8217; and &#8216;plugins&#8217; folders into your Eclipse home directory<br />
5. Unzip your latest click libraries and keep it for later <img src='http://www.softwarepassion.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
6. Start your Eclipse IDE and create new &#8216;Dynamic Web Project&#8217;<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/dynamic_web_project.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/dynamic_web_project-254x300.jpg" alt="" title="dynamic_web_project" width="254" height="300" class="aligncenter size-medium wp-image-361" /></a><br />
Choose target name, in this case &#8216;ClickDemo2&#8242;, select your target runtime as Tomcat 6+ etc.<br />
7. Under configuration combo box, select custom and click &#8216;Modify&#8217;<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/custom_click_config.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/custom_click_config-300x265.jpg" alt="" title="custom_click_config" width="300" height="265" class="aligncenter size-medium wp-image-359" /></a><br />
8. Select &#8216;Click&#8217; in Project Facet List and save the configuration as click config<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/click_config.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/click_config-300x232.jpg" alt="" title="click_config" width="300" height="232" class="aligncenter size-medium wp-image-357" /></a><br />
9. Once you have your configuration created, dynamic web project screen should look like in the following screenshot:<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/custom_click_config2.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/custom_click_config2-255x300.jpg" alt="" title="custom_click_config2" width="255" height="300" class="aligncenter size-medium wp-image-360" /></a><br />
10. The rest of the settings you can leave as it is, just click &#8216;Next&#8217; up to the point when you finish creating new dynamic web project.<br />
11. After your project is created it will have the structure like in the following screen:<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/clickdemo_project_structure.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/clickdemo_project_structure-274x300.jpg" alt="" title="clickdemo_project_structure" width="274" height="300" class="aligncenter size-medium wp-image-358" /></a><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Notice that there are click libraries from version 1.5, which is no good, we want to use the latest version which is 2.1.0.<br />
12. Copy the files &#8216;click-2.1.0.jar&#8217; and &#8216;click-extras-2.1.0.jar&#8217; into the same lib folder where the old libraries are found.<br />
13. Delete old libraries and refresh the project tree under eclipse (right click on the project node and select &#8216;Refresh&#8217;), now you will see the new libraries come up in the lib folder.<br />
14. Open your web.xml file under &#8216;WebContent/WEB-INF/&#8217; folder and change the class name of the main Click Servlet, from &#8216;net.sf.click.ClickServlet&#8217; to &#8216;org.apache.click.ClickServlet&#8217; in &#8217;servlet-class&#8217; declaration.<br />
15. With Eclipse, select the project node and click &#8216;New&#8217; -> &#8216;Other&#8217;, choose &#8216;Click Page&#8217; under &#8216;click&#8217; directory.<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/new_click_page.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/new_click_page-300x285.jpg" alt="" title="new_click_page" width="300" height="285" class="aligncenter size-medium wp-image-362" /></a><br />
16. Fill out the necessary fields for your new click page as below:<br />
<a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/new_click_page2.jpg" rel="lightbox[356]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/new_click_page2-264x300.jpg" alt="" title="new_click_page2" width="264" height="300" class="aligncenter size-medium wp-image-363" /></a><br />
17. Name the file &#8216;index.htm&#8217; and click &#8216;Finish&#8217;<br />
18. Under the page java source file, fix the Page class by using the page from the: org.apache.click.Page instead of the old path.</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">package</span> <span class="co2">com.softwarepassion</span><span class="sy0">;</span><br />
<br />
<span class="kw1">import</span> <span class="co2">java.util.Date</span><span class="sy0">;</span><br />
<br />
<span class="kw1">import</span> <span class="co2">org.apache.click.Page</span><span class="sy0">;</span><br />
<br />
<br />
<span class="kw1">public</span> <span class="kw1">class</span> Index <span class="kw1">extends</span> Page <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Date</span></a> time <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Date</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw1">public</span> Index<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; addModel<span class="br0">&#40;</span><span class="st0">&quot;time&quot;</span>, time<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
<span class="br0">&#125;</span></div></div>
<p>Modify your &#8216;index.htm&#8217; using html editor to look something like this:</p>
<div class="codecolorer-container html4strict " style="overflow:auto;white-space:nowrap;width:535px"><div class="html4strict codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc2">&lt;<a href="http://december.com/html/4/element/html.html"><span class="kw2">html</span></a>&gt;</span><br />
&nbsp; <span class="sc2">&lt;<a href="http://december.com/html/4/element/head.html"><span class="kw2">head</span></a>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<a href="http://december.com/html/4/element/meta.html"><span class="kw2">META</span></a> <span class="kw3">HTTP-EQUIV</span><span class="sy0">=</span><span class="st0">&quot;Content-Type&quot;</span> <span class="kw3">CONTENT</span><span class="sy0">=</span><span class="st0">&quot;text/html;charset=UTF-8&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<a href="http://december.com/html/4/element/title.html"><span class="kw2">title</span></a>&gt;</span>Blank<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/title.html"><span class="kw2">title</span></a>&gt;</span><br />
&nbsp; &nbsp; $imports<br />
&nbsp; <span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/head.html"><span class="kw2">head</span></a>&gt;</span><br />
&nbsp; <span class="sc2">&lt;<a href="http://december.com/html/4/element/body.html"><span class="kw2">body</span></a>&gt;</span><br />
&nbsp; $time<br />
&nbsp; <span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/body.html"><span class="kw2">body</span></a>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/html.html"><span class="kw2">html</span></a>&gt;</span></div></div>
<p>19. Start up your project in tomcat. The page should display current time!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Additional Comments:<br />
I know that this is just a quickfix, and I just cannot belive that there is no proper eclipse plugin using the latest click framework, which would be up to date, if you know any, than please comment and save me and my readers precious time.</p>
<p>Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/getting-started-with-apache-click-and-eclipse-galileo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Jasperberry &#8211; the most dynamic reports ever.</title>
		<link>http://www.softwarepassion.com/jasperberry-the-most-dynamic-reports-ever/</link>
		<comments>http://www.softwarepassion.com/jasperberry-the-most-dynamic-reports-ever/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 09:03:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[jasperberry]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=350</guid>
		<description><![CDATA[Today I will describe in short my latest and simplest quick and dirty trick, generating jasper report dynamically. Jasperberry is a component written very quickly to help me
generate pdf report in a situation where I don&#8217;t know the number of columns I will have, I don&#8217;t know their widths, the data they contain etc, all [...]]]></description>
			<content:encoded><![CDATA[<p>Today I will describe in short my latest and simplest quick and dirty trick, generating jasper report dynamically. Jasperberry is a component written very quickly to help me<br />
generate pdf report in a situation where I don&#8217;t know the number of columns I will have, I don&#8217;t know their widths, the data they contain etc, all is generated at runtime dynamically.<br />
I know that there is DynamicJasper project but it seems to be dead, and its dead in a very strange way, I mean, I see that the authors commit new code but there is no chance to get any support unless, I guess, you pay for it.<br />
With dynamic jasper I couldn&#8217;t generate report with polish fonts displayed properly, tried many different tricks, no support on the forum, no support on stack overflow, no nothing. After 2 days I have realized that I will write my own library quicker to solve my problem than get an answer from the dynamic jasper community (if there is any).<br />
So here we have: jasperberry!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Don&#8217;t expect too much from it but if you want to display simple table with data, dynamic columns, adjustable fonts and colors than this is it.</p>
<p>In fact you don&#8217;t have to even know object properties to generate the report, we will use Apache DynaBeans for that:</p>
<p>This is a simple example code snipped showing you how to get started with the simplest and most dynamic reporting library ever (as well as lacking features probably but we hope its enough for simple projects)</p>
<p>This example assumes the following:</p>
<p>1. You want simple report<br />
2. You dont have to know the object which properties you want to display in advance, by this I mean you can create report columns dynamically, and by using apache dyna beans your objects don&#8217;t have to even exists. You just dynamically create them and inject them into the report.</p>
<p>Here is an example test class showing you how to use jasperberry, for more info please contact us directly at softberries.com<br />
Code:</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw1">class</span> JRXMLBuilderTest <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw1">static</span> List<span class="sy0">&lt;</span>JBColumnBean<span class="sy0">&gt;</span> columns<span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">public</span> JRXMLBuilderTest<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; @BeforeClass<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> setUpClass<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw1">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns <span class="sy0">=</span> <span class="kw1">new</span> ArrayList<span class="sy0">&lt;</span>JBColumnBean<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col1 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col2 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col3 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col4 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col5 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col6 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JBColumnBean col7 <span class="sy0">=</span> <span class="kw1">new</span> JBColumnBean<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col1.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">60</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col1.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;name&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col1.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Imię&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col2.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">60</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col2.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;surname&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col2.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Nazwisko&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col3.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">160</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col3.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;comment&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col3.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Komentarz&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col4.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col4.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;comment2&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col4.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Komentarz&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col5.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col5.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;comment3&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col5.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Komentarz&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col6.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col6.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;comment4&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col6.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Komentarz&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col7.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col7.<span class="me1">setProperty</span><span class="br0">&#40;</span><span class="st0">&quot;comment5&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; col7.<span class="me1">setTitle</span><span class="br0">&#40;</span><span class="st0">&quot;Komentarz&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col1<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col2<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col3<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col4<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col5<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col6<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; columns.<span class="me1">add</span><span class="br0">&#40;</span>col7<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; @AfterClass<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> tearDownClass<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw1">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; @Before<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> setUp<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; @After<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> tearDown<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="co3">/** * Test of build method, of class JRXMLBuilder. */</span><br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> testBuild<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;build&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span class="sy0">&lt;</span>JBReportElement<span class="sy0">&gt;</span> elements <span class="sy0">=</span> <span class="kw1">new</span> ArrayList<span class="sy0">&lt;</span>JBReportElement<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//col header font </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JBFont colHeaderFont <span class="sy0">=</span> <span class="kw1">new</span> JBFont<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colHeaderFont.<span class="me1">setBold</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colHeaderFont.<span class="me1">setSize</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colHeaderFont.<span class="me1">setForegroundColor</span><span class="br0">&#40;</span><span class="st0">&quot;#555555&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//detail font </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JBFont detailFont <span class="sy0">=</span> <span class="kw1">new</span> JBFont<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detailFont.<span class="me1">setSize</span><span class="br0">&#40;</span><span class="nu0">6</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detailFont.<span class="me1">setForegroundColor</span><span class="br0">&#40;</span><span class="st0">&quot;#000000&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detailFont.<span class="me1">setPdfEncoding</span><span class="br0">&#40;</span><span class="st0">&quot;Cp1257&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JBPage page <span class="sy0">=</span> <span class="kw1">new</span> JBPage<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JBReport report <span class="sy0">=</span> <span class="kw1">new</span> JBReport<span class="br0">&#40;</span>page, colHeaderFont, detailFont, <span class="st0">&quot;#CCCCFF&quot;</span>, <span class="st0">&quot;#DEDEDE&quot;</span>, <span class="st0">&quot;#FFFFFF&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JBFont titleFont <span class="sy0">=</span> <span class="kw1">new</span> JBFont<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; titleFont.<span class="me1">setBold</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; titleFont.<span class="me1">setSize</span><span class="br0">&#40;</span><span class="nu0">20</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; titleFont.<span class="me1">setForegroundColor</span><span class="br0">&#40;</span><span class="st0">&quot;#FF0000&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; titleFont.<span class="me1">setPdfEncoding</span><span class="br0">&#40;</span><span class="st0">&quot;Cp1257&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//add title elements </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elements.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw1">new</span> JBStaticTextElement<span class="br0">&#40;</span><span class="st0">&quot;Hello World!&quot;</span>, <span class="nu0">450</span>, <span class="nu0">10</span>, <span class="nu0">300</span>, titleFont<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elements.<span class="me1">add</span><span class="br0">&#40;</span><span class="kw1">new</span> JBImageElement<span class="br0">&#40;</span><span class="st0">&quot;C:<span class="es0">\\</span><span class="es0">\\</span>Documents and Settings<span class="es0">\\</span><span class="es0">\\</span>admin<span class="es0">\\</span><span class="es0">\\</span>Moje dokumenty<span class="es0">\\</span><span class="es0">\\</span>NetBeansProjects<span class="es0">\\</span><span class="es0">\\</span>JASPER_BERRY<span class="es0">\\</span><span class="es0">\\</span>test.jpg&quot;</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">350</span>, <span class="nu0">242</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; report.<span class="me1">setTitleElements</span><span class="br0">&#40;</span>elements<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JRXMLBuilder instance <span class="sy0">=</span> <span class="kw1">new</span> JRXMLBuilder<span class="br0">&#40;</span>columns, report<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">boolean</span> expResult <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">boolean</span> result <span class="sy0">=</span> instance.<span class="me1">build</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JasperReport jr <span class="sy0">=</span> JasperCompileManager.<span class="me1">compileReport</span><span class="br0">&#40;</span><span class="st0">&quot;jasperberry_by_softberries.jrxml&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//PREPARE SOME DATA </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DynaProperty<span class="br0">&#91;</span><span class="br0">&#93;</span> props <span class="sy0">=</span> <span class="kw1">new</span> DynaProperty<span class="br0">&#91;</span>columns.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> columns.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; props<span class="br0">&#91;</span>i<span class="br0">&#93;</span> <span class="sy0">=</span> <span class="kw1">new</span> DynaProperty<span class="br0">&#40;</span>columns.<span class="me1">get</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.<span class="me1">getProperty</span><span class="br0">&#40;</span><span class="br0">&#41;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a>.<span class="kw1">class</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BasicDynaClass dynaClass <span class="sy0">=</span> <span class="kw1">new</span> BasicDynaClass<span class="br0">&#40;</span><span class="st0">&quot;tester&quot;</span>, <span class="kw2">null</span>, props<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span class="sy0">&lt;</span>DynaBean<span class="sy0">&gt;</span> beans <span class="sy0">=</span> <span class="kw1">new</span> ArrayList<span class="sy0">&lt;</span>DynaBean<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&lt;</span> <span class="nu0">100</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DynaBean db <span class="sy0">=</span> dynaClass.<span class="me1">newInstance</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;name&quot;</span>, <span class="st0">&quot;Krzysztof &quot;</span> <span class="sy0">+</span> i<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;surname&quot;</span>, <span class="st0">&quot;Grajek &quot;</span> <span class="sy0">+</span> i<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;comment&quot;</span>, <span class="st0">&quot;Komentarz &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;comment2&quot;</span>, <span class="st0">&quot;Komentarz &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;comment3&quot;</span>, <span class="st0">&quot;Komentarz &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;comment4&quot;</span>, <span class="st0">&quot;Komentarz &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; db.<span class="me1">set</span><span class="br0">&#40;</span><span class="st0">&quot;comment5&quot;</span>, <span class="st0">&quot;Komentarz &quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; beans.<span class="me1">add</span><span class="br0">&#40;</span>db<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JasperPrint jp <span class="sy0">=</span> JasperFillManager.<span class="me1">fillReport</span><span class="br0">&#40;</span>jr, <span class="kw2">null</span>, <span class="kw1">new</span> JRBeanCollectionDataSource<span class="br0">&#40;</span>beans<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JasperExportManager.<span class="me1">exportReportToPdfFile</span><span class="br0">&#40;</span>jp, <span class="st0">&quot;jasperberry.pdf&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span class="br0">&#40;</span>expResult, result<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a> ex<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Logger.<span class="me1">getLogger</span><span class="br0">&#40;</span>JRXMLBuilderTest.<span class="kw1">class</span>.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">log</span><span class="br0">&#40;</span>Level.<span class="me1">SEVERE</span>, <span class="kw2">null</span>, ex<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p>You should find similar snippet in a test suite of the project.<br />
The project itself is licensed under LGPL and its available from sourceforge <a href="http://sourceforge.net/projects/jasperberry/">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/jasperberry-the-most-dynamic-reports-ever/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Deploy your Java Application with IzPack Installer</title>
		<link>http://www.softwarepassion.com/deploy-your-java-application-with-izpack-installer/</link>
		<comments>http://www.softwarepassion.com/deploy-your-java-application-with-izpack-installer/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 18:16:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[desktop installer]]></category>
		<category><![CDATA[izpack]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=341</guid>
		<description><![CDATA[<span style="max-width: 100px; display: block; float: left;"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/izpack_directory-300x168.png" alt="izpack installer folders" title="izpack installer content" width="100" height="100"/></span><span style="margin: 0px; padding-left: 10px; display: block; max-width: 370px; float: left;">Deploy your Java Application with IzPack Installer</span>]]></description>
			<content:encoded><![CDATA[<p>This is a short tutorial on how to create simple IzPack based installation solution on windows platform with all standard features like: desktop shortcut, start menu item shortcut, copying libraries, folders, documentation into one of the ProgramFiles folder on the windows machine.<br />
I had some problems creating windows shortcuts mysefl and I wanted to share the experience so other people can find it quicker.<br />
Here you go.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
1. First download and install IzPack itself from: <a href="http://izpack.org">izpack website</a></p>
<p>2. Prepare the application you want to make installable, I use Netbeans to build most of my Java apps, but I guess for all other ide&#8217;s the results after all are the same, we end up with SomeApp.jar file and a bunch of libraries we used to build it.<br />
On the Netbeans platform all the files needed to launch the application we have build end up in &#8216;dist&#8217; folder as a subfolder of our project main folder. If you have used any libraries to build your desktop application they will be included in the lib folder (yourproject/dist/lib/).</p>
<p>3. Now, once we have all the main ingredients (our application and installer) we need to connect it together. Create the folder anywhere on your machine, and call it for example &#8217;softwarepassion&#8217;. </p>
<p>4. Put your jar file together with the &#8216;lib&#8217; folder into the &#8217;softwarepassion&#8217; catalog.</p>
<p>5. Now we need to add some native libraries for Izpack to be able to add windows shortcuts on the desktop and start menu. Create &#8216;bin&#8217; folder under the &#8217;softwarepassion&#8217; folder and copy whole &#8216;native&#8217; content found in your izpack installation into the &#8216;bin&#8217; folder of your root &#8217;softwarepassion&#8217; catalog.<br />
You can find the native folder inside your IzPack installation directory, normally under: &#8216;C:\Program Files\IzPack\bin&#8217;</p>
<p>6. Create your application icon file and add it to your &#8217;softwarepasison&#8217; catalog. I call mine &#8216;exe.ico&#8217;.</p>
<p>7. Now comes the hardest part to get initially but after you build your first installer it all gets clear and easy <img src='http://www.softwarepassion.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
We need to prepare two separate xml files: one called &#8216;install.xml&#8217; and another one called &#8217;shortcutSpec.xml&#8217;.</p>
<p>The content of both example files is listed below:<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="codecolorer-container xml " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;iso-8859-1&quot;</span> <span class="re0">standalone</span>=<span class="st0">&quot;yes&quot;</span> <span class="re2">?&gt;</span></span><br />
<br />
<span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp;A sample installation file.</span><br />
<span class="sc-1"> &nbsp; &nbsp;Use it as a base for your own installers :-)</span><br />
<span class="sc-1"> &nbsp; &nbsp;</span><br />
<span class="sc-1"> &nbsp; &nbsp;To compile it :</span><br />
<span class="sc-1"> &nbsp; &nbsp;- go in the bin directory where you installed IzPack</span><br />
<span class="sc-1"> &nbsp; &nbsp;- call &quot;compile ../sample/install.xml -b ../sample&quot;</span><br />
<span class="sc-1">--&gt;</span><br />
<br />
<span class="sc3"><span class="re1">&lt;installation</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span><span class="re2">&gt;</span></span><br />
<br />
&nbsp; &nbsp; <span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The info section.</span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The meaning of the tags should be natural ...</span><br />
<span class="sc-1"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;info<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;appname<span class="re2">&gt;</span></span></span>SoftwarePassion Application<span class="sc3"><span class="re1">&lt;/appname<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;appversion<span class="re2">&gt;</span></span></span>1.0<span class="sc3"><span class="re1">&lt;/appversion<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;authors<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;author</span> <span class="re0">name</span>=<span class="st0">&quot;Softberries Krzysztof Grajek&quot;</span> <span class="re0">email</span>=<span class="st0">&quot;customer.service@softberries.com&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/authors<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;url<span class="re2">&gt;</span></span></span>http://www.softwarepassion.com/<span class="sc3"><span class="re1">&lt;/url<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/info<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The gui preferences indication.</span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;Sets the installer window to 640x480. It will not be able to change the size.</span><br />
<span class="sc-1"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;guiprefs</span> <span class="re0">width</span>=<span class="st0">&quot;640&quot;</span> <span class="re0">height</span>=<span class="st0">&quot;480&quot;</span> <span class="re0">resizable</span>=<span class="st0">&quot;yes&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;variables<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;variable</span> <span class="re0">name</span>=<span class="st0">&quot;DesktopShortcutCheckboxEnabled&quot;</span> <span class="re0">value</span>=<span class="st0">&quot;true&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/variables<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The locale section.</span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;Asks here to include the English and French langpacks.</span><br />
<span class="sc-1"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;locale<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;langpack</span> <span class="re0">iso3</span>=<span class="st0">&quot;pol&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;langpack</span> <span class="re0">iso3</span>=<span class="st0">&quot;eng&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/locale<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The resources section.</span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The ids must be these ones if you want to use the LicencePanel and/or the InfoPanel.</span><br />
<span class="sc-1"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;resources<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;res</span> <span class="re0">src</span>=<span class="st0">&quot;shortcutSpec.xml&quot;</span> <span class="re0">id</span>=<span class="st0">&quot;shortcutSpec.xml&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;res</span> <span class="re0">id</span>=<span class="st0">&quot;LicencePanel.licence&quot;</span> <span class="re0">src</span>=<span class="st0">&quot;Licence.txt&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;res</span> <span class="re0">id</span>=<span class="st0">&quot;InfoPanel.info&quot;</span> <span class="re0">src</span>=<span class="st0">&quot;Readme.txt&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/resources<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The panels section.</span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;We indicate here which panels we want to use. The order will be respected.</span><br />
<span class="sc-1"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panels<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;HelloPanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;LicencePanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;TargetPanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;PacksPanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;InstallPanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;ShortcutPanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;panel</span> <span class="re0">classname</span>=<span class="st0">&quot;FinishPanel&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/panels<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc-1">&lt;!-- </span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;The packs section.</span><br />
<span class="sc-1"> &nbsp; &nbsp; &nbsp; &nbsp;We specify here our packs.</span><br />
<span class="sc-1"> &nbsp; &nbsp;--&gt;</span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;packs<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;pack</span> <span class="re0">name</span>=<span class="st0">&quot;Base&quot;</span> <span class="re0">required</span>=<span class="st0">&quot;yes&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;description<span class="re2">&gt;</span></span></span>The base files<span class="sc3"><span class="re1">&lt;/description<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;file</span> <span class="re0">src</span>=<span class="st0">&quot;Readme.txt&quot;</span> <span class="re0">targetdir</span>=<span class="st0">&quot;$INSTALL_PATH&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;file</span> <span class="re0">src</span>=<span class="st0">&quot;Licence.txt&quot;</span> <span class="re0">targetdir</span>=<span class="st0">&quot;$INSTALL_PATH&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;file</span> <span class="re0">src</span>=<span class="st0">&quot;exe.ico&quot;</span> <span class="re0">targetdir</span>=<span class="st0">&quot;$INSTALL_PATH&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;file</span> <span class="re0">src</span>=<span class="st0">&quot;SoftwarePassionHelloIzPack.jar&quot;</span> <span class="re0">targetdir</span>=<span class="st0">&quot;$INSTALL_PATH&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;fileset</span> <span class="re0">dir</span>=<span class="st0">&quot;lib&quot;</span> <span class="re0">targetdir</span>=<span class="st0">&quot;$INSTALL_PATH\lib&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;include</span> <span class="re0">name</span>=<span class="st0">&quot;**&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/fileset<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/pack<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/packs<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;native</span> <span class="re0">type</span>=<span class="st0">&quot;izpack&quot;</span> <span class="re0">name</span>=<span class="st0">&quot;ShellLink.dll&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;native</span> <span class="re0">type</span>=<span class="st0">&quot;3rdparty&quot;</span> <span class="re0">name</span>=<span class="st0">&quot;COIOSHelper.dll&quot;</span> <span class="re0">stage</span>=<span class="st0">&quot;both&quot;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;os</span> <span class="re0">family</span>=<span class="st0">&quot;windows&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/native<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/installation<span class="re2">&gt;</span></span></span></div></div>
<p>And the one for windows shortcuts:</p>
<div class="codecolorer-container xml " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span> <span class="re0">standalone</span>=<span class="st0">&quot;yes&quot;</span> <span class="re2">?&gt;</span></span><br />
<br />
<span class="sc3"><span class="re1">&lt;shortcuts<span class="re2">&gt;</span></span></span><br />
<br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;skipIfNotSupported</span><span class="re2">/&gt;</span></span><br />
<br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;programGroup</span> <span class="re0">defaultName</span>=<span class="st0">&quot;Siemens AWORT&quot;</span> <span class="re0">location</span>=<span class="st0">&quot;applications&quot;</span><span class="re2">/&gt;</span></span><br />
<br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;shortcut</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">name</span>=<span class="st0">&quot;SoftwarePassion Application&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">programGroup</span>=<span class="st0">&quot;yes&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">desktop</span>=<span class="st0">&quot;yes&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">applications</span>=<span class="st0">&quot;no&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">startMenu</span>=<span class="st0">&quot;yes&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">startup</span>=<span class="st0">&quot;no&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">target</span>=<span class="st0">&quot;$INSTALL_PATH\SoftwarePassionHelloIzPack.jar&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">commandLine</span>=<span class="st0">&quot;&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">description</span>=<span class="st0">&quot;Software Passion Example App&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">iconFile</span>=<span class="st0">&quot;$INSTALL_PATH\exe.ico&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">iconIndex</span>=<span class="st0">&quot;0&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">initialState</span>=<span class="st0">&quot;noShow&quot;</span><span class="re2">&gt;</span></span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;createForPack</span> <span class="re0">name</span>=<span class="st0">&quot;Base&quot;</span><span class="re2">/&gt;</span></span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="sc3"><span class="re1">&lt;/shortcut<span class="re2">&gt;</span></span></span><br />
&nbsp;<br />
<br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;shortcut</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">name</span>=<span class="st0">&quot;Software Passion Example App Uninstaller&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">programGroup</span>=<span class="st0">&quot;yes&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">desktop</span>=<span class="st0">&quot;no&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">applications</span>=<span class="st0">&quot;no&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">startMenu</span>=<span class="st0">&quot;no&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">startup</span>=<span class="st0">&quot;no&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">target</span>=<span class="st0">&quot;$INSTALL_PATH\Uninstaller\uninstaller.jar&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">commandLine</span>=<span class="st0">&quot;&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">iconFile</span>=<span class="st0">&quot;%SystemRoot%\system32\SHELL32.dll&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">iconIndex</span>=<span class="st0">&quot;31&quot;</span></span><br />
<span class="sc3"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">description</span>=<span class="st0">&quot;Uninstall SoftwarePassion Example&quot;</span><span class="re2">&gt;</span></span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;createForPack</span> <span class="re0">name</span>=<span class="st0">&quot;Base&quot;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/shortcut<span class="re2">&gt;</span></span></span><br />
<br />
<span class="sc3"><span class="re1">&lt;/shortcuts<span class="re2">&gt;</span></span></span></div></div>
<p>8. Example installation script contains both Readme.txt and Licence.txt which you can add to your &#8217;softwarepassion&#8217; folder.<br />
9. Once you have it all in one place, you should have a structure like in the following screenshot:</p>
<p><a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/izpack_directory.png" rel="lightbox[341]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/izpack_directory-300x168.png" alt="izpack_directory" title="izpack_directory" width="300" height="168" class="aligncenter size-medium wp-image-342" /></a></p>
<p>10. Now assuming that your &#8217;softwarepassion&#8217; folder has been placed directly on the c: drive, execute the following command:</p>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:535px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">C:\Program Files\IzPack\bin<span class="sy0">&gt;</span>compile c:\softwarepassion\install.xml <span class="re5">-b</span> c:\softwarepassion</div></div>
<p>Assuming that IzPack itself was installed at: C:\Program Files\IzPack</p>
<p>This will produce install.jar file which is your installer.</p>
<p>11. If you dont&#8217; want your end users to click on the &#8216;jar&#8217; file as not everybody knows they can do that, you can add Izpack launcher app which will launch it automatically, or use another tool to create an executable called launch4j</p>
<p>You have to admit that it was an easy one!!!!!</p>
<p>Happy Installing!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Download example files from <a href="http://www.softwarepassion.com/softwarepassion.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/deploy-your-java-application-with-izpack-installer/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Add &#8216;count #&#8217; column to JTable</title>
		<link>http://www.softwarepassion.com/add-count-column-to-jtable/</link>
		<comments>http://www.softwarepassion.com/add-count-column-to-jtable/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 14:18:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Graphics And Design]]></category>
		<category><![CDATA[Learning Materials]]></category>
		<category><![CDATA[count column]]></category>
		<category><![CDATA[jxtable]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=336</guid>
		<description><![CDATA[<span style="max-width: 100px; display: block; float: left;"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/count_jtable_column-300x179.png" alt="jtable count column" title="jtable # column" width="100" height="100"/></span><span style="margin: 0px; padding-left: 10px; display: block; max-width: 370px; float: left;">How to add 'count#' column in JTable</span>]]></description>
			<content:encoded><![CDATA[<p>Important note first: This is mostly not my code, I was strugling with this problem for some time, I couldn&#8217;t google it at all, and one day, I&#8217;ve just found it. Now I use it in one of my projects but I cannot find the original post again, therefore I have decided to post it on my blog (slightly modified version of the original) so other people with similar problem will have a better chance of finding the solution.<br />
So, the idea is very simple. The whole point of displaying additional column which is kind of independent from the other columns is to simply use another table. This way you can sort one table by column and the number column will not sort with it. &#8211; thats exactly what I was looking for and I guess its kind of popular problem.<br />
Becouse you put two tables in one scroll pane the gui looks like its just one column!<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
I have created one simple method to apply this technique to any tables in my application (I use JXTable actually but JTable will do as well)</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">private</span> <span class="kw4">void</span> addLPColumn<span class="br0">&#40;</span>JXTable table, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajscrollpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JScrollPane</span></a> scp<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTable</span></a> rowTable <span class="sy0">=</span> <span class="kw1">new</span> RowNumberTable<span class="br0">&#40;</span>table<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scp.<span class="me1">setRowHeaderView</span><span class="br0">&#40;</span>rowTable<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scp.<span class="me1">setCorner</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajscrollpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JScrollPane</span></a>.<span class="me1">UPPER_LEFT_CORNER</span>, rowTable.<span class="me1">getTableHeader</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scp.<span class="me1">repaint</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>RowNumberTable is simple one column table displaying the &#8216;count&#8217; number of rows in the second table. </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw1">class</span> RowNumberTable <span class="kw1">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTable</span></a><br />
&nbsp; &nbsp; <span class="kw1">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Achangelistener+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">ChangeListener</span></a>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Apropertychangelistener+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">PropertyChangeListener</span></a><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTable</span></a> main<span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">public</span> RowNumberTable<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTable</span></a> table<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; main <span class="sy0">=</span> table<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; main.<span class="me1">addPropertyChangeListener</span><span class="br0">&#40;</span> <span class="kw1">this</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; setFocusable<span class="br0">&#40;</span> <span class="kw2">false</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setAutoCreateColumnsFromModel<span class="br0">&#40;</span> <span class="kw2">false</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setModel<span class="br0">&#40;</span> main.<span class="me1">getModel</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setSelectionModel<span class="br0">&#40;</span> main.<span class="me1">getSelectionModel</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Atablecolumn+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">TableColumn</span></a> column <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Atablecolumn+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">TableColumn</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; column.<span class="me1">setHeaderValue</span><span class="br0">&#40;</span><span class="st0">&quot;Lp.&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; addColumn<span class="br0">&#40;</span> column <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; column.<span class="me1">setCellRenderer</span><span class="br0">&#40;</span><span class="kw1">new</span> RowNumberRenderer<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; getColumnModel<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getColumn</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>.<span class="me1">setPreferredWidth</span><span class="br0">&#40;</span><span class="nu0">40</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setPreferredScrollableViewportSize<span class="br0">&#40;</span>getPreferredSize<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> addNotify<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">super</span>.<span class="me1">addNotify</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acomponent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Component</span></a> c <span class="sy0">=</span> getParent<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &nbsp;Keep scrolling of the row table in sync with the main table.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>c <span class="kw1">instanceof</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajviewport+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JViewport</span></a><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajviewport+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JViewport</span></a> viewport <span class="sy0">=</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajviewport+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JViewport</span></a><span class="br0">&#41;</span>c<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; viewport.<span class="me1">addChangeListener</span><span class="br0">&#40;</span> <span class="kw1">this</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="coMULTI">/*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Delegate method to main table<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">int</span> getRowCount<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>main <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> main.<span class="me1">getRowCount</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">0</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">int</span> getRowHeight<span class="br0">&#40;</span><span class="kw4">int</span> row<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> main.<span class="me1">getRowHeight</span><span class="br0">&#40;</span>row<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="coMULTI">/*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;This table does not use any data from the main TableModel,<br />
&nbsp; &nbsp; &nbsp;* &nbsp;so just return a value based on the row parameter.<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Object</span></a> getValueAt<span class="br0">&#40;</span><span class="kw4">int</span> row, <span class="kw4">int</span> column<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Integer</span></a>.<span class="me1">toString</span><span class="br0">&#40;</span>row <span class="sy0">+</span> <span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="coMULTI">/*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Don't edit data in the main TableModel by mistake<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">boolean</span> isCellEditable<span class="br0">&#40;</span><span class="kw4">int</span> row, <span class="kw4">int</span> column<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="co1">//</span><br />
<span class="co1">// &nbsp;Implement the ChangeListener</span><br />
<span class="co1">//</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> stateChanged<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Achangeevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">ChangeEvent</span></a> e<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &nbsp;Keep the scrolling of the row table in sync with main table</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajviewport+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JViewport</span></a> viewport <span class="sy0">=</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajviewport+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JViewport</span></a><span class="br0">&#41;</span> e.<span class="me1">getSource</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajscrollpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JScrollPane</span></a> scrollPane <span class="sy0">=</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajscrollpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JScrollPane</span></a><span class="br0">&#41;</span>viewport.<span class="me1">getParent</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scrollPane.<span class="me1">getVerticalScrollBar</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">setValue</span><span class="br0">&#40;</span>viewport.<span class="me1">getViewPosition</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">y</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="co1">//</span><br />
<span class="co1">// &nbsp;Implement the PropertyChangeListener</span><br />
<span class="co1">//</span><br />
&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> propertyChange<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Apropertychangeevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">PropertyChangeEvent</span></a> e<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// &nbsp;Keep the row table in sync with the main table</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="st0">&quot;selectionModel&quot;</span>.<span class="me1">equals</span><span class="br0">&#40;</span>e.<span class="me1">getPropertyName</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSelectionModel<span class="br0">&#40;</span> main.<span class="me1">getSelectionModel</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="st0">&quot;model&quot;</span>.<span class="me1">equals</span><span class="br0">&#40;</span>e.<span class="me1">getPropertyName</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setModel<span class="br0">&#40;</span> main.<span class="me1">getModel</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="coMULTI">/*<br />
&nbsp; &nbsp; &nbsp;* &nbsp;Borrow the renderer from JDK1.4.2 table header<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <span class="kw1">static</span> <span class="kw1">class</span> RowNumberRenderer <span class="kw1">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adefaulttablecellrenderer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">DefaultTableCellRenderer</span></a><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> RowNumberRenderer<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setHorizontalAlignment<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajlabel+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JLabel</span></a>.<span class="me1">CENTER</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acomponent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Component</span></a> getTableCellRendererComponent<span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTable</span></a> table, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Object</span></a> value, <span class="kw4">boolean</span> isSelected, <span class="kw4">boolean</span> hasFocus, <span class="kw4">int</span> row, <span class="kw4">int</span> column<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>table <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtableheader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTableHeader</span></a> header <span class="sy0">=</span> table.<span class="me1">getTableHeader</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>header <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setForeground<span class="br0">&#40;</span>header.<span class="me1">getForeground</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setBackground<span class="br0">&#40;</span>header.<span class="me1">getBackground</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setFont<span class="br0">&#40;</span>header.<span class="me1">getFont</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>isSelected<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setFont<span class="br0">&#40;</span> getFont<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">deriveFont</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afont+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Font</span></a>.<span class="me1">BOLD</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setText<span class="br0">&#40;</span><span class="br0">&#40;</span>value <span class="sy0">==</span> <span class="kw2">null</span><span class="br0">&#41;</span> <span class="sy0">?</span> <span class="st0">&quot;&quot;</span> <span class="sy0">:</span> value.<span class="me1">toString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setBorder<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Auimanager+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">UIManager</span></a>.<span class="me1">getBorder</span><span class="br0">&#40;</span><span class="st0">&quot;TableHeader.cellBorder&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p><a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/count_jtable_column.png" rel="lightbox[336]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/count_jtable_column-300x179.png" alt="count_jtable_column" title="count_jtable_column" width="300" height="179" class="aligncenter size-medium wp-image-337" /></a></p>
<p>In my case the &#8216;count&#8217; column is called &#8216;Lp.&#8217; &#8211; in polish </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
I have created one simple method to apply this technique to any tables in my application (I use JXTable actually but JTable will do as well)</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:535px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">private</span> <span class="kw4">void</span> addLPColumn<span class="br0">&#40;</span>JXTable table, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajscrollpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JScrollPane</span></a> scp<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajtable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JTable</span></a> rowTable <span class="sy0">=</span> <span class="kw1">new</span> RowNumberTable<span class="br0">&#40;</span>table<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scp.<span class="me1">setRowHeaderView</span><span class="br0">&#40;</span>rowTable<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scp.<span class="me1">setCorner</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ajscrollpane+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">JScrollPane</span></a>.<span class="me1">UPPER_LEFT_CORNER</span>, rowTable.<span class="me1">getTableHeader</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scp.<span class="me1">repaint</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></div></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/add-count-column-to-jtable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 Simple, But Useful CSS Properties</title>
		<link>http://www.softwarepassion.com/5-simple-but-useful-css-properties/</link>
		<comments>http://www.softwarepassion.com/5-simple-but-useful-css-properties/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 18:19:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Graphics And Design]]></category>
		<category><![CDATA[css tips]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=294</guid>
		<description><![CDATA[<span style="max-width: 100px; display: block; float: left;"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/useful_css_properties-150x150.jpg" alt="jquery" title="daniweb 10 linux distros" width="100" height="100" class="size-thumbnail wp-image-278" /></span><span style="margin: 0px; padding-left: 10px; display: block; max-width: 370px; float: left;">5 Simple, But Useful CSS Properties</span> ]]></description>
			<content:encoded><![CDATA[<p><a href="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/useful_css_properties.jpg" rel="lightbox[294]"><img src="http://softwarepassion.s3.amazonaws.com/wp-content/uploads/useful_css_properties-150x150.jpg" alt="useful_css_properties" title="useful_css_properties" width="150" height="150" class="alignleft size-thumbnail wp-image-295" /></a><br />
5 Simple, But Useful CSS Properties<br />
<script type="text/javascript"><!--
google_ad_client = "pub-3015706834207881";
/* 468x15, utworzono 09-11-19 */
google_ad_slot = "3912330401";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<a href="http://www.webdesignerwall.com/tutorials/5-simple-but-useful-css-properties/">5 Simple, But Useful CSS Properties</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/5-simple-but-useful-css-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Your personal SMS Gateway with C#</title>
		<link>http://www.softwarepassion.com/your-personal-sms-gateway-with-c/</link>
		<comments>http://www.softwarepassion.com/your-personal-sms-gateway-with-c/#comments</comments>
		<pubDate>Fri, 08 May 2009 09:17:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=173</guid>
		<description><![CDATA[Today I will describe simple but effective way to send sms from your computer using your mobile phone and a short C# application. I&#8217;m using Nokia 6070 but I guess any phone which has the ability to send SMS through AT commands will do.
First of all you would have to have a mobile phone connected [...]]]></description>
			<content:encoded><![CDATA[<p>Today I will describe simple but effective way to send sms from your computer using your mobile phone and a short C# application. I&#8217;m using Nokia 6070 but I guess any phone which has the ability to send SMS through AT commands will do.<br />
First of all you would have to have a mobile phone connected to the computer through a cable and a driver for this cable installed. You need a driver to transfrom your usb cable into a serial interface.<br />
To check if your phone is able to send sms using AT Commands please visit the following <a href="http://wiki.forum.nokia.com/index.php/Using_AT_commands_to_send_and_read_SMS">link</a> and test it through the hyper terminal.<br />
Once this is working you can easily do the same using C# and SerialPort class.<br />
Here is a complete source which will transform your computer into your personal SMS Gateway:</p>
<div class="codecolorer-container csharp " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">using</span> <span class="co3">System</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Collections.Generic</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Linq</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Text</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.IO.Ports</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Threading</span><span class="sy0">;</span><br />
<br />
<span class="kw1">namespace</span> SMSSender<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw4">class</span> Program<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">static</span> SerialPort p9 <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> SerialPort<span class="br0">&#40;</span><span class="st0">&quot;COM9&quot;</span>, <span class="nu0">9600</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">static</span> <span class="kw1">void</span> Main<span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">DataReceived</span> <span class="sy0">+=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> SerialDataReceivedEventHandler<span class="br0">&#40;</span>p9_DataReceived<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Open</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Write</span><span class="br0">&#40;</span><span class="st0">&quot;ATrn&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.<span class="me1">Sleep</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Write</span><span class="br0">&#40;</span><span class="st0">&quot;AT+CMGF=1rn&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.<span class="me1">Sleep</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Write</span><span class="br0">&#40;</span><span class="st0">&quot;AT+CMGS=&quot;</span><span class="nu0">123456789</span><span class="st0">&quot;rn&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.<span class="me1">Sleep</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Write</span><span class="br0">&#40;</span><span class="st0">&quot;!personal gateway!n&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thread.<span class="me1">Sleep</span><span class="br0">&#40;</span><span class="nu0">500</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Write</span><span class="br0">&#40;</span><span class="st0">&quot;Hello Worldx1Arn&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p9.<span class="me1">Close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">static</span> <span class="kw1">void</span> p9_DataReceived<span class="br0">&#40;</span><span class="kw4">object</span> sender, SerialDataReceivedEventArgs e<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot;Data received..&quot;</span> <span class="sy0">+</span> p9.<span class="me1">ReadLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="kw1">catch</span><span class="br0">&#40;</span>Exception ex<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p>&#8220;123456789&#8243; stands for the mobile phone number where you want to send SMS to, and &#8216;x1A&#8217; is a replacement for <Ctrl>+<Z> which you have to issue when you want to send sms on the GSM modem.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/your-personal-sms-gateway-with-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Forms application with Splash Screen</title>
		<link>http://www.softwarepassion.com/windows-forms-application-with-splash-screen/</link>
		<comments>http://www.softwarepassion.com/windows-forms-application-with-splash-screen/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 14:22:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.softwarepassion.com/?p=152</guid>
		<description><![CDATA[Today I will describe how to add simple yet effective splash screen functionality using Visual Basic assembly goodness. To show exactly how to do that I will create a simple project describing step by step what you have to do to create splash screen for your win forms application.
First of all, lets create a simple [...]]]></description>
			<content:encoded><![CDATA[<p>Today I will describe how to add simple yet effective splash screen functionality using Visual Basic assembly goodness. To show exactly how to do that I will create a simple project describing step by step what you have to do to create splash screen for your win forms application.<br />
First of all, lets create a simple windows forms application, open up Visual Studio and select File -> New -> Project.</p>
<p><img src="http://www.softwarepassion.com/wp-content/screen1-300x212.png" alt="screen1" title="screen1" width="300" height="212" class="aligncenter size-medium wp-image-153" /></p>
<p>Select &#8216;Windows Forms Application&#8217;, set the name for your project and click &#8216;OK&#8217;.<br />
This creates simple windows forms application which you can start up by clicking &#8216;F5&#8242;.</p>
<p>Lets say that my Form1.cs is the main form of the application I want to start up. Before launching Form1 I want to create a splash screen to load some additional resources, connect to the database or remote server. The project structure for now should look like this:</p>
<p><img src="http://www.softwarepassion.com/wp-content/screen2-300x171.png" alt="screen2" title="screen2" width="300" height="171" class="aligncenter size-medium wp-image-154" /></p>
<p>Now, when we have our application created and ready to be launched we create a splash screen for it. We create the splash screen itself first and than modify a bit the code to launch our splash before the main application starts.<br />
Our splash itself would be another form which we modify a bit to look like, well, like a splash screen <img src='http://www.softwarepassion.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
Lets add another form to our project:</p>
<p><img src="http://www.softwarepassion.com/wp-content/screen3-300x170.jpg" alt="screen3" title="screen3" width="300" height="170" class="aligncenter size-medium wp-image-155" /></p>
<p>and name it &#8216;SplashForm.cs&#8217;.  This form will be launched until our main form loads. To make it look like a proper splash screen we have to find the property named &#8216;FormBorderStyle&#8217; and set it to &#8216;None&#8217;, as well as set the &#8216;StartPostion&#8217; to &#8216;CenterScreen&#8217;.<br />
You can prettify the splash form by adding picture boxes, labels etc to add your custom graphics etc. I&#8217;m going to add a simple label and animated gif loader to my form. You can use animated gifs generated on this <a href="http://www.ajaxload.info/">website</a> which I found very cool.</p>
<p><img src="http://www.softwarepassion.com/wp-content/screen4-300x164.png" alt="screen4" title="screen4" width="300" height="164" class="aligncenter size-medium wp-image-156" /></p>
<p>Ok, our splash screen is ready, now we need to modify the code which starts our application to show the splash screen and destroy it when the main form is ready.<br />
Originally, when you create the windows forms type of project a simple class called &#8216;Program&#8217; gets created. You can find the source for this class inside &#8216;Program.cs&#8217; file. It should look somthing like this:</p>
<div class="codecolorer-container csharp " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">using</span> <span class="co3">System</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Collections.Generic</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Linq</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Windows.Forms</span><span class="sy0">;</span><br />
<br />
<span class="kw1">namespace</span> TestFormApplication<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">static</span> <span class="kw4">class</span> Program<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// The main entry point for the application.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>STAThread<span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">static</span> <span class="kw1">void</span> Main<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.<span class="me1">EnableVisualStyles</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.<span class="me1">SetCompatibleTextRenderingDefault</span><span class="br0">&#40;</span><span class="kw1">false</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.<span class="me1">Run</span><span class="br0">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> Form1<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p>In order to use our splash form created earlier correctly we need to modify this code a bit. First, add a reference to Microsoft.VisualBasic assembly found under .NET tab. Go to you project references and find the following:<br />
<img src="http://www.softwarepassion.com/wp-content/screen5-300x252.png" alt="screen5" title="screen5" width="300" height="252" class="aligncenter size-medium wp-image-157" /><br />
Next, add the folowing piece of code among other &#8216;using&#8217; statements on top of the &#8216;Program&#8217; class file:</p>
<div class="codecolorer-container csharp " style="overflow:auto;white-space:nowrap;width:535px"><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">using</span> <span class="co3">Microsoft.VisualBasic</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">Microsoft.VisualBasic.ApplicationServices</span><span class="sy0">;</span></div></div>
<p>Once this is done you are ready to use the VB goodness. Add the following code below the Program class, inside the same namespace as the Program class itself:</p>
<div class="codecolorer-container csharp " style="overflow:auto;white-space:nowrap;width:535px"><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw4">class</span> SplashApp <span class="sy0">:</span> WindowsFormsApplicationBase<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">protected</span> <span class="kw1">override</span> <span class="kw1">void</span> OnCreateSplashScreen<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">SplashScreen</span> <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> SplashForm<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">protected</span> <span class="kw1">override</span> <span class="kw1">void</span> OnCreateMainForm<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Connect to db, remote server or anything you like in here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw5">System.<span class="me1">Threading</span></span>.<span class="me1">Thread</span>.<span class="me1">Sleep</span><span class="br0">&#40;</span><span class="nu0">2000</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//create your main form and the SplashForm will close here automatically</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">MainForm</span> <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> Form1<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div></div>
<p>You have to modify the main method a bit as well, use the main with arguments option and start you application using our newly created SplashApp class, the full source code for the Program.cs will look like this:</p>
<div class="codecolorer-container csharp " style="overflow:auto;white-space:nowrap;width:535px;height:300px"><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">using</span> <span class="co3">System</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Collections.Generic</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Linq</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">System.Windows.Forms</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">Microsoft.VisualBasic</span><span class="sy0">;</span><br />
<span class="kw1">using</span> <span class="co3">Microsoft.VisualBasic.ApplicationServices</span><span class="sy0">;</span><br />
<br />
<span class="kw1">namespace</span> TestFormApplication<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">static</span> <span class="kw4">class</span> Program<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &lt;summary&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// The main entry point for the application.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">/// &lt;/summary&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>STAThread<span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">static</span> <span class="kw1">void</span> Main<span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.<span class="me1">EnableVisualStyles</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application.<span class="me1">SetCompatibleTextRenderingDefault</span><span class="br0">&#40;</span><span class="kw1">false</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> SplashApp<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">Run</span><span class="br0">&#40;</span>args<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">class</span> SplashApp <span class="sy0">:</span> WindowsFormsApplicationBase<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">protected</span> <span class="kw1">override</span> <span class="kw1">void</span> OnCreateSplashScreen<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">SplashScreen</span> <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> SplashForm<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">protected</span> <span class="kw1">override</span> <span class="kw1">void</span> OnCreateMainForm<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//Connect to db, remote server or anything you like in here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw5">System.<span class="me1">Threading</span></span>.<span class="me1">Thread</span>.<span class="me1">Sleep</span><span class="br0">&#40;</span><span class="nu0">2000</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//create your main form and the SplashForm will close here automatically</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">MainForm</span> <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> Form1<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></div>
<p>You can download the whole VS 2008 solution file <a href="http://storage43.com/file/show/74">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.softwarepassion.com/windows-forms-application-with-splash-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
