<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>pekalicious</title>
	
	<link>http://pekalicious.com/blog</link>
	<description />
	<lastBuildDate>Thu, 12 Jan 2012 00:53:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/pekalicious" /><feedburner:info uri="pekalicious" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Introducing ‘The History of Light’</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/NI9NSlnTjWg/</link>
		<comments>http://pekalicious.com/blog/introducing-the-history-of-light/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 00:53:57 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=688</guid>
		<description><![CDATA[The History of Light is a Lights Out-type of puzzle game: There is a grid of lights that are either on or off and your goal is to switch them all off. Clicking on a single tile will toggle it, and its adjacent tiles, on or off. There are five worlds in The History of [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_689" class="wp-caption right" style="width: 226px"><a href="http://pekalicious.com/blog/wp-content/uploads/2012/01/main.png" rel="lightbox[688]"><img class="size-full wp-image-689" title="The History of Light" src="http://pekalicious.com/blog/wp-content/uploads/2012/01/main.png" alt="The History of Light" width="216" height="384" /></a><p class="wp-caption-text">The History of Light - Main Menu</p></div>
<p><a title="The History of Light" href="http://pekalicious.com/thehistoryoflight/">The History of Light</a> is a <a title="Light's Out (game)" href="https://en.wikipedia.org/wiki/Lights_Out_%28game%29">Lights Out</a>-type of puzzle game: There is a grid of lights that are either on or off and your goal is to switch them all off. Clicking on a single tile will toggle it, and its adjacent tiles, on or off.</p>
<p>There are five worlds in The History of Light, each with 20 levels and a new unique mechanic. On the second world for example, the player is introduced to the concept of bombs. In addition, the last 8 levels of each world has a bigger grid.</p>
<p>The game was developed by me and Dimitris Xanthopoulos. Audio was provided (with permission) by Brandon Morris, Louis Hostos and various other artists found at <a title="Open Game Art" href="http://opengameart.org/">OpenGameArt.org</a>.</p>
<p>The game is currently available at the <a title="The History of Light (Ovi store)" href="http://store.ovi.com/content/234366">Ovi store</a> and its official website is <a title="The History of Light" href="http://pekalicious.com/thehistoryoflight">http://pekalicious.com/thehistoryoflight</a>.</p>
<h2>Post Mortem</h2>
<p>While the development of the game took us less than a week (what with Dimitris learning QML and me learning C++) I kept tweaking and refining it until I felt comfortable enough to release it. However, I spent most of the time on the interface rather than the level design which, I believe, will cost me a lot of downloads. I have already got some feedback from some friends and I plan on working on them in the next couple of weeks.</p>
<p>One of the biggest things that didn&#8217;t get to the release was music. The game has one track for the menu and one when playing a level. My initial design was one track for each world from the very talented people at OpenGameArt. Unfortunately, the size of the game leaped from 5MB to more than 15MB. I believe that 15MB is not an acceptable size for a mobile game, so I had to cut it down. I&#8217;m thinking of making a &#8220;Director&#8217;s cut&#8221; edition of the game with full audio. At least that way the player will have a choice of the size of download.</p>
<p>Finally, let&#8217;s talk about the elephant in the room: The Ovi Store. I know that, in this day and age, with iOS and Android being the center of everything, many will wonder why we chose the Ovi Store. iOS was an easy decision; the cost was simply too high: buying a Mac, an iPhone, creating an iOS account etc, etc. Android vs Ovi Store needed a little more thinking. I have a good background in Java but nothing in C++ while Dimitris has a good background in C++ but no Java. Both of us didn&#8217;t have any experience in Android Development or Symbian, so, as far as development time went, they where both the same. It all came down to competition: Android has A LOT of competition compared to Ovi. A friend of Dimitris had previously released a couple of Symbian apps and he provided some good insights on how his apps went. So we went for Ovi after that.</p>
<p>Developing for Symbian had many hiccups. Especially in the audio department. It took me about two weeks to figure out how to fade in/fade out the background music and play sound effects. I finally came with a work around, but I didn&#8217;t like it at all.</p>
<p>There is another platform out there that I would really like to work on: Windows Phone 7. Especially because I am already working on <a title="Xanor" href="http://pekalicious.com/blog/introducing-xanor/">an XNA game</a> which is supported (with some limitations) on the platform. We&#8217;ll see. For the mean time, have a look at the other project Dimitris has released on the Ovi Store: <a title="Galaxy Jump" href="http://store.ovi.com/content/223619">Galaxy Jump</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=NI9NSlnTjWg:gnPo90UY678:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=NI9NSlnTjWg:gnPo90UY678:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=NI9NSlnTjWg:gnPo90UY678:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=NI9NSlnTjWg:gnPo90UY678:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=NI9NSlnTjWg:gnPo90UY678:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/NI9NSlnTjWg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-the-history-of-light/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-the-history-of-light/</feedburner:origLink></item>
		<item>
		<title>Working on Xanor: The Dialogue System</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/s_PFRtzylLA/</link>
		<comments>http://pekalicious.com/blog/working-on-xanor-the-dialogue-system/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 11:43:25 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[dialogue]]></category>
		<category><![CDATA[mass effect]]></category>
		<category><![CDATA[open diagram]]></category>
		<category><![CDATA[xanor]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=645</guid>
		<description><![CDATA[As promised, I will be making a series of posts regarding my upcoming video game, Xanor. In this post I will be demonstrating the dialogue system. Before I began designing a whole new dialogue system, I thought I&#8217;d first google what other people have created. The very first hit was this Mass Effect dialogue system. [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Introducing Xanor - pekalicious" href="http://pekalicious.com/blog/introducing-xanor/">As promised</a>, I will be making a series of posts regarding my upcoming video game, Xanor. In this post I will be demonstrating the dialogue system.</p>
<p><span id="more-645"></span>Before I began designing a whole new dialogue system, I thought I&#8217;d first google what other people have created. The very first hit was this <a title="Mass Effect Dialogue Sample" href="http://www.catalinzima.com/2009/04/mass-effect-dialogue-sample/">Mass Effect dialogue system</a>. Not bad I saids to myself. So I<del> copied it</del> investigated it and ended up using a similar system.</p>
<p>At its very core, the dialogue system consists of Branches and Hubs. A branch is a series of speech lines; the sentences a character says as well as his pose (remember, this is a 2D game, so no animations). A branch either terminates the dialogue, or reaches a hub. A hub has a list of branches which basically are the player&#8217;s options.</p>
<p>A hub can be of three types:</p>
<ul>
<li>a Normal Hub<br />
which contains a list of branches,</li>
<li>an End Hub<br />
which terminates the dialogue,</li>
<li>or an Info Hub<br />
which returns to the original hub once the branch ends</li>
</ul>
<p>Pretty straightforward, don&#8217;t you think? Here is a diagram to clear any confusion:</p>
<div id="attachment_674" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/08/dialogue-diagram1.png" rel="lightbox[645]"><img class="size-medium wp-image-674" title="dialogue-diagram" src="http://pekalicious.com/blog/wp-content/uploads/2011/08/dialogue-diagram1-300x241.png" alt="Dialogue Diagram" width="300" height="241" /></a><p class="wp-caption-text">Dialogue Diagram</p></div>
<p>While the Mass Effect sample was great, it was way more complicated than what I needed. First of all, Mass Effect has a morality system, so the branches where either good, bad or neutral and they were placed <a title="Mass Effect Dialogue Wheel" href="http://masseffect.wikia.com/wiki/Dialogue">around a wheel</a>. For Info branches, you had to select a special &#8220;Investigate&#8221; option to view them.</p>
<p>I have no morality system, and I don&#8217;t want my info branches to seem any different than any normal branch. So I simplified it by making info branches nothing more than a branch that has its NextHubID set to the same Hub as the one it was choosen from. I also eliminated the limitation of having 3 branches (good, bad and neutral) to unlimited. Finally, I removed the sound property since I won&#8217;t be having any voice overs (sigh).</p>
<p>On the designing side, the sample comes with an editor. Which doesn&#8217;t really look easy to understand:</p>
<div id="attachment_676" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/08/masseffect-editor.png" rel="lightbox[645]"><img class="size-medium wp-image-676" title="masseffect-editor" src="http://pekalicious.com/blog/wp-content/uploads/2011/08/masseffect-editor-300x215.png" alt="Mass Effect Dialogue Editor" width="300" height="215" /></a><p class="wp-caption-text">Editor for the Mass Effect-style Dialogue System</p></div>
<p>So I made a more designer-friendly tool:</p>
<div id="attachment_678" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/08/xanor-dialogue-editor.png" rel="lightbox[645]"><img class="size-medium wp-image-678" title="xanor-dialogue-editor" src="http://pekalicious.com/blog/wp-content/uploads/2011/08/xanor-dialogue-editor-300x225.png" alt="Xanor Dialogue Editor" width="300" height="225" /></a><p class="wp-caption-text">Xanor Dialogue Editor</p></div>
<p>Reminds you of something?</p>
<p>To do this, I had to test a LOT of diagramming libraries: <a title="Netron" href="http://sourceforge.net/projects/netron/">Netron</a>, <a title="Piccolo2D" href="http://www.piccolo2d.org/">Piccolo2D</a>, <a title="QuickGraph" href="http://quickgraph.codeplex.com/">QuickGraph </a>etc, etc. I ended up with <a title="Open Diagram" href="http://opendiagram.codeplex.com/">Open Diagram</a> mainly for its simplicity.</p>
<p>Here is a boring video that demonstrates how the whole system works (the interesting part is at 1:53):</p>
<p><a href="http://www.youtube.com/watch?v=NZKRSQcZpy4"><img src="http://img.youtube.com/vi/NZKRSQcZpy4/2.jpg"></a></p>
<p><a href="http://www.youtube.com/watch?v=NZKRSQcZpy4">Click here</a> to view the video on YouTube.</p>

<p>Now that I am able to create the dialogues and basically write the entire story of the game, I have to focus on a much more important system: the battle system.</p>
<p>So, stay tuned!</p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">QuickGraph</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=s_PFRtzylLA:8c22DIX1Gk4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=s_PFRtzylLA:8c22DIX1Gk4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=s_PFRtzylLA:8c22DIX1Gk4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=s_PFRtzylLA:8c22DIX1Gk4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=s_PFRtzylLA:8c22DIX1Gk4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/s_PFRtzylLA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/working-on-xanor-the-dialogue-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/working-on-xanor-the-dialogue-system/</feedburner:origLink></item>
		<item>
		<title>Introducing ‘Xanor’ (WIP)</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/eiV17ZjXhxc/</link>
		<comments>http://pekalicious.com/blog/introducing-xanor/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 21:16:35 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[ai game dev]]></category>
		<category><![CDATA[game ai conference]]></category>
		<category><![CDATA[starplanner]]></category>
		<category><![CDATA[xanor]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=575</guid>
		<description><![CDATA[Last month I attended the Paris Game AI Conference. Now I&#8217;m back and things look awesome! Time to get back to work! &#160; First of all, I would like to thank Alex Champandard for giving me the opportunity of having a poster of my BSc dissertation, StarPlanner, at this year&#8217;s Paris Game AI Conference. In [...]]]></description>
			<content:encoded><![CDATA[<p>Last month I attended the Paris Game AI Conference. Now I&#8217;m back and things look awesome! Time to get back to work!</p>
<p><span id="more-575"></span></p>
<p>&nbsp;</p>
<p>First of all, I would like to thank Alex Champandard for giving me the opportunity of having a poster of my BSc dissertation, <a title="StarPlanner" href="http://pekalicious.com/starplanner">StarPlanner</a>, at this year&#8217;s <a title="Paris Game AI Conference" href="http://gameaiconf.com">Paris Game AI Conference</a>. In fact, I am thankful to a number of people that helped me during and after the development of the project. Jeff Orkin who linked StarPlanner&#8217;s website on the <a title="Goal-Oriented Action Planning" href="http://web.media.mit.edu/~jorkin/goap.html">official GOAP website</a>, Eric Jacopin who used the source code as learning material for an internship and provided plenty of feedback, <a title="Edmund Long" href="http://www.edmundlong.com">Edmund Long</a> for his implementation of GOAP in C++ and William van der Sterren for his help in the <a title="AIGameDev forums" href="http://aigamedev.com/forums/">AiGameDev</a> forums.</p>
<div id="attachment_652" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/07/starplanner_gameaiconf_poster1.jpg" rel="lightbox[575]"><img class="size-medium wp-image-652 " title="starplanner_gameaiconf_poster" src="http://pekalicious.com/blog/wp-content/uploads/2011/07/starplanner_gameaiconf_poster1-300x212.jpg" alt="" width="300" height="212" /></a><p class="wp-caption-text">Wallpaper for the Paris Game AI Conference 2011</p></div>
<p>Planning was a big thing this year, having a short tutorial talk from  Luke Dicken and an entire panel about its pros, cons and future, which  meant that my project was an awesome conversation starter ;) So I met a lot of great people in person. Can&#8217;t wait for next  year&#8217;s conference.</p>
<p>Anyway, on with the main subject.</p>
<p>About ten months ago, I began working on a vertical shooter using the XNA framework. However, I had to stop for a while due to Greek&#8217;s obligatory military training. That is (finally) over and it&#8217;s time to get back to business.</p>
<h1>The Pitch</h1>
<p>Xanor (Working Title) is a vertical shooter (like Aero Fighters) with many JRPG elements such as Leveling up, Mana Power, Talent Trees and Side Quests.</p>
<h1>Game Overview</h1>
<p>Xanor is a top-down space shooter where the player assumes the role of Reik, a pilot who became an outcast as a result of a failed mission that caused his hometown to vanish. With the help of his trusted but, somewhat, clumsy engineer, Mishi, and an advanced alien technology, his mission is now to regain his identity back by reestablishing his hometown as the dominant empire it once was.</p>
<p>Thanks to Mishi&#8217;s talent, the player is able to upgrade his spaceship with powerful weaponry and defenses. Four types of spaceships are available to choose from:</p>
<ul>
<li>The Spartan<br />
This is the most dexterous ship of all. It is able to equip a vast amount of weapons that are easily upgraded.</li>
<li>The M109<br />
This ship is able to receive an extensive amount of damage and still be able to attack.</li>
<li>The Ulonar<br />
The Ulonar becomes more powerful the more damage it receives.</li>
<li>The Summoner<br />
The agile drones that orbit around the Summoner is a great way to get the job done.</li>
</ul>
<p>To make a living and be able to pay the upgrades he needs, Reik hunts down bounties. He has gained a reputation for being fierce and, as a consequence, he is hired by many to do their dirty work (such as escorting ships or flying spacecrafts). Among the scumbags and lowlifes that usually hire him, there is this young woman who awards him with something more valuable than money: information on how to destroy the federation and complete his mission.</p>
<p>However, the destruction of the federation has catastrophic consequences.</p>
<h1>Technical</h1>
<p>Xanor is written in C# using Microsoft&#8217;s XNA Game Studio 4.0 framework. The goal is to release it as an XBOX Live Indie Game. Here is a short video I did a while back (the art is currently placeholder sprites made &#8211; with permission &#8211; by <a title="Squirrel Squid @DeviantArt" href="http://squirrelsquid.deviantart.com/">SquirrelSquid</a>):</p>
<p style="text-align: center;"><p><a href="http://www.youtube.com/watch?v=vBn02M8bOw8"><img src="http://img.youtube.com/vi/vBn02M8bOw8/2.jpg"></a></p>
<p><a href="http://www.youtube.com/watch?v=vBn02M8bOw8">Click here</a> to view the video on YouTube.</p>
</p>
<p>Under the hood Xanor is going over massive structural changes. I fell into the classic deep hierarchy problem and, after some research, I began working on a <a title="Evolve Your Hierarchy" href="http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/">component-based entity system</a>.</p>
<p>The good news is that last week I was fortunate enough to meet <a title="SiGra" href="http://sigra1989.deviantart.com/">SiGra</a>, who will be creating Xanor&#8217;s characters. Thus, currently I am focusing on developing a dialogue system.</p>
<p style="text-align: center;">&nbsp;</p>
<div id="attachment_661" class="wp-caption aligncenter" style="width: 240px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/07/mechanic_resized.jpg" rel="lightbox[575]"><img class="size-medium wp-image-661 " title="The young female mechanic side-kick." src="http://pekalicious.com/blog/wp-content/uploads/2011/07/mechanic_resized-230x300.jpg" alt="" width="230" height="300" /></a><p class="wp-caption-text">Mishi</p></div>
<p>&nbsp;</p>
<p>I will be posting updates of Xanor&#8217;s development as each component of the engine is stable enough for a demonstration. So stay tuned!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=eiV17ZjXhxc:g2hG7m-ZJwc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=eiV17ZjXhxc:g2hG7m-ZJwc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=eiV17ZjXhxc:g2hG7m-ZJwc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=eiV17ZjXhxc:g2hG7m-ZJwc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=eiV17ZjXhxc:g2hG7m-ZJwc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/eiV17ZjXhxc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-xanor/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-xanor/</feedburner:origLink></item>
		<item>
		<title>Training!</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/HZl9tJwhvpc/</link>
		<comments>http://pekalicious.com/blog/training/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 18:53:02 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[comic]]></category>
		<category><![CDATA[gameai]]></category>
		<category><![CDATA[xkcd]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=632</guid>
		<description><![CDATA[I&#8217;ve been into Game AI a lot lately, and in one of the interviews I watched, the developer had to wait 2-3 days while the AI of the game trained its Neural Network. I then ran into xkcd&#8217;s classic Compiling comic and&#8230; Training &#160;]]></description>
			<content:encoded><![CDATA[<p><a title="StarPlanner" href="http://pekalicious.com/blog/introducing-my-dissertation-starplanner/">I&#8217;ve been into Game AI a lot lately</a>, and in one of the interviews I watched, the developer had to wait 2-3 days while the AI of the game trained its Neural Network. I then ran into <a title="Compiling - XKCD" href="http://xkcd.com/303/">xkcd&#8217;s classic Compiling comic</a> and&#8230;</p>
<p><span id="more-632"></span></p>
<div class="mceTemp mceIEcenter" style="text-align: center;">
<dl id="attachment_633" class="wp-caption aligncenter" style="width: 310px;">
<dt class="wp-caption-dt"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/04/training.png" rel="lightbox[632]"><img class="size-medium wp-image-633   " title="'Are you playing?' 'No, I'm training the AI!'" src="http://pekalicious.com/blog/wp-content/uploads/2011/04/training-300x261.png" alt="Training" width="300" height="261" /></a></dt>
<dd class="wp-caption-dd">Training</dd>
</dl>
</div>
<p style="text-align: center;">&nbsp;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=HZl9tJwhvpc:MEwWTES1VMs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=HZl9tJwhvpc:MEwWTES1VMs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=HZl9tJwhvpc:MEwWTES1VMs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=HZl9tJwhvpc:MEwWTES1VMs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=HZl9tJwhvpc:MEwWTES1VMs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/HZl9tJwhvpc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/training/</feedburner:origLink></item>
		<item>
		<title>Introducing my dissertation: StarPlanner</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/v5jJ-Jf-uj8/</link>
		<comments>http://pekalicious.com/blog/introducing-my-dissertation-starplanner/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 21:46:53 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[bwapi]]></category>
		<category><![CDATA[city college]]></category>
		<category><![CDATA[dissertation]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[gameai]]></category>
		<category><![CDATA[goap]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jbridge]]></category>
		<category><![CDATA[starcraft]]></category>
		<category><![CDATA[starplanner]]></category>
		<category><![CDATA[thesis]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=576</guid>
		<description><![CDATA[It&#8217;s about time I shared my final year project with the world. Due to my country&#8217;s military obligations I joined the army right after I got my bachelor, which meant that I didn&#8217;t have time to polish some stuff. However, I had some time off, so here it is! My dissertation: StarPlanner &#8211; Demonstrating the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s about time I shared my final year project with the world. Due to my country&#8217;s military obligations I joined the army right after I got my bachelor, which meant that I didn&#8217;t have time to polish some stuff. However, I had some time off, so here it is! My dissertation: StarPlanner &#8211; Demonstrating the Use of AI Planning in a Video Game.</p>
<p><span id="more-576"></span></p>
<p style="text-align: center;"><p><a href="http://www.youtube.com/watch?v=NWQTl_s-WAY"><img src="http://img.youtube.com/vi/NWQTl_s-WAY/2.jpg"></a></p>
<p><a href="http://www.youtube.com/watch?v=NWQTl_s-WAY">Click here</a> to view the video on YouTube.</p>
</p>
<p>StarPlanner is a StarCraft bot that implements a <a title="Goal-Oriented Action Planning (GOAP)" href="http://web.media.mit.edu/~jorkin/goap.html">Goal-Oriented Action Planning (GOAP)</a> agent architecture. The architecture includes a Blackboard for subsystem communications, a working memory and an regressive planner for decision making. There are two levels of planning in StarPlanner: a high level strategic planner that creates a plan depending on the current state of the game and a low level build planner that creates a plan to build or train the required units in order to carry out the high level plan.</p>
<p style="text-align: center;"><p><a href="http://www.youtube.com/watch?v=fTe1Wxd9i9I"><img src="http://img.youtube.com/vi/fTe1Wxd9i9I/2.jpg"></a></p>
<p><a href="http://www.youtube.com/watch?v=fTe1Wxd9i9I">Click here</a> to view the video on YouTube.</p>
</p>
<p>StarPlanner is written in Java and uses <a title="BWAPI" href="http://code.google.com/p/bwapi/">BWAPI</a> (specifically, <a title="JBridge" href="http://code.google.com/p/bwapi-jbridge/">JBridge</a>) to communicate with StarCraft. The project architecture is layered: at the lowest level there is an A* search engine. On top of that there is a generic GOAP architecture that uses the A* engine for its searching. And, finally, StarPlanner is a concrete implementation for StarCraft of the generic GOAP architecture.</p>
<div id="attachment_579" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2011/03/layers.png" rel="lightbox[576]"><img class="size-medium wp-image-579 " title="StarPlanner Layers" src="http://pekalicious.com/blog/wp-content/uploads/2011/03/layers-300x118.png" alt="StarPlanner Layers" width="300" height="118" /></a><p class="wp-caption-text">StarPlanner Layers</p></div>
<p>Full source code and documentation along with the full report and videos as delivered to City College can be found at <a title="StarPlanner" href="http://pekalicious.com/starplanner/ppeikidis.html ">http://pekalicious.com/starplanner/ppeikidis.html </a></p>
<h2>Post Mortem</h2>
<p>I wish I had more time for the project and added a lot more actions from which the bot could choose. The biggest time-waster was trying to create an XNA 2D game from scratch. That was way before I discovered BWAPI in the middle of the semester. Of course, even after I used BWAPI, a lot of the functionality had to be created: controlling units, training units, etc. Although there is an extension of BWAPI called <a title="BWSAL" href="http://code.google.com/p/bwsal/">BWSAL</a> that handles a lot of this for you, this wasn&#8217;t ported in Java.</p>
<p>The GOAP architecture was done thanks to <a title="Edmund Long" href="http://www.edmundlong.com/">Edmund Long</a>&#8216;s MSc thesis &#8220;Enhanced NPC Behavior using Goal Oriented Action Planning&#8221;. Edmund implemented it in C++ in a 2D simulation he developed from scratch. I ported the code in Java and split it into the layers described earlier. This was this easy part.</p>
<p>The hardest part was modeling an RTS game in order to make decisions. Planning is a searching algorithm that uses a world state, a goal state and a set of actions to produce a plan (a sequence of actions that, when executed, will change the world state to the goal state). The actions contain preconditions and effects. Preconditions of an action are essentially a list of properties that must be true in the world state, otherwise the action cannot be performed. If all preconditions are true, the action can be selected. A heuristic is used to decide which of the valid actions should be chosen. Finally, the effects of the chosen action alter the world state and the cycle continues until the world state is the desired one.</p>
<p>So, initially the idea was to use any data type as a precondition and an effect. The world state then would have a set of integers, booleans or anything really. So, for example, when I wanted to create a plan that trained 3 Marines, the goal state would have an integer &#8220;marines = 3&#8243; as a precondition. The plan then would be &#8220;Build Barrack&#8221; -&gt; &#8220;Train Marine&#8221; -&gt; &#8220;Train Marine&#8221; -&gt; &#8220;Train Marine&#8221;. Unfortunately this was harder than I thought so I went with a boolean-based approach. However, this solution has other limitations. For example, a precondition can be &#8220;haveMarines = true&#8221;. But how many marines? 10? 12? 100? So finally, I decoupled the units from the buildings and now training is the responsibility of a TrainManager who constantly trains units  (as long as there are resources) until a new plan is created.</p>
<p>The bot is not, by any stretch of the imagination, a good AI player. It only does a limited number of actions and hardly can win a game (except when you are demonstrating it *cough*custom*cough*maps*cough). There where two reasons for this: first, I had to create managers that could successfully move units, battle against enemies, use unit abilities, upgrade, etc, etc, etc. And second, at the time, I wasn&#8217;t that much of a good player in StarCraft. I&#8217;m no pro, mind you, but I have been following the StarCraft II community (which, incidentally, launched right in the middle of my project) and realized how bad a player I was. A big thanks to Sean Plott and his <a title="Day[9] Daily" href="http://day9tv.blip.tv/">Day[9] Daily</a> videos who made it clear what is actually a strategy and what is a tactic in an RTS game.</p>
<p>All these delays also made it impossible to enter the first <a title="StarCraft AI Competition" href="http://eis.ucsc.edu/StarCraftAICompetition">StarCraft AI Competition</a> that was announced a while before I began the project. Another lost opportunity.</p>
<h2>Final Thoughts</h2>
<p>Even though a lot of things could have gone better, I am really satisfied with the results. When I started my dissertation 2 years ago, planning was a big deal in the world of Game AI, so I was kind of proud. I still am. In fact, I loved so much working on the project, that my professional goal is to work in the Game AI industry!</p>
<p>After attending the first <a title="Hellenic Artificial Intelligence Summer School" href="http://www.icsd.aegean.gr/haiss09/">Hellenic Artificial Intelligence Summer School</a>, I&#8217;m on my way to this year&#8217;s <a title="Paris Game AI Conference" href="http://gameaiconf.com/">Paris Game AI Conference</a>. All the while creating my first XNA video game for XBOX Live (coming up in a future post).</p>
<p>So yeah, once I&#8217;m done with my country&#8217;s military obligations this August, I&#8217;m flying to USA <a title="Panagiotis Peikidis CV" href="http://pekalicious.com/cv">looking for a job</a>. Wish me good luck!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=v5jJ-Jf-uj8:oLYSZsA05Eo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=v5jJ-Jf-uj8:oLYSZsA05Eo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=v5jJ-Jf-uj8:oLYSZsA05Eo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=v5jJ-Jf-uj8:oLYSZsA05Eo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=v5jJ-Jf-uj8:oLYSZsA05Eo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/v5jJ-Jf-uj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-my-dissertation-starplanner/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-my-dissertation-starplanner/</feedburner:origLink></item>
		<item>
		<title>CodeSOD: How to avoid the expensive “If-then-else” statement</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/jxvxsBg0yR0/</link>
		<comments>http://pekalicious.com/blog/codesod-how-to-avoid-the-expensive-if-statement/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 19:25:58 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=518</guid>
		<description><![CDATA[About two years ago, in Data Structures and Algorithms, our lecturer briefly talked about the &#8220;If-then-else&#8221; statement and how much expensive it is as an operation. Leaving us with many questions, I extensively researched the topic and found out that the word &#8220;expensive&#8221; is, well, really relative. Nevertheless, a particular student found a way to [...]]]></description>
			<content:encoded><![CDATA[<p>About two years ago, in Data Structures and Algorithms, our lecturer briefly talked about the &#8220;If-then-else&#8221; statement and how much expensive it is as an operation. Leaving us with many questions, <a title="StackOverflow: Is &quot;If&quot; expensive?" href="http://stackoverflow.com/questions/315306/is-if-expensive">I extensively researched the topic</a> and found out that the word &#8220;expensive&#8221; is, well, really relative. Nevertheless, a particular student found a way to avoid the cost&#8230;</p>
<p><span id="more-518"></span></p>
<p>First of all, here is how much you need to worry about the cost of the &#8220;If-then-else&#8221; statement: not at all*. You see, an &#8220;If-then-else&#8221; statement in your code creates a branch in the instruction list. If the statement is true, the processor will execute a particular instruction list, if not, it will execute another. The processor, always striving for optimizations, tries to predict which way the branch will go and pre-load the instructions. A wrong prediction is known as a &#8220;<a title="Google: Branch Misprediction" href="http://www.google.com/search?q=branch misprediction">Branch Miprediction</a>&#8220;. The penalty? In modern microprocessors, 10-20 cycles<a href="#wikipedia-branch-misprediction">[1]</a>. Your average 2.4GHz CPU can perform 2.400.000.000 cycles/second. That is 2.4 billion cycles per seconds, in case you haven&#8217;t noticed. Billions&#8230; Per second&#8230; So I think it&#8217;s pretty safe to say that this has absolutely no affect in your average pet-project.</p>
<p>One particular student, however, took this at face value and came up with the following gem:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> code<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000;  font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> code == <span style="color: #cc66cc;">101</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doThis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000;  font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> code == <span style="color: #cc66cc;">102</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doThat<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000;  font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> code == <span style="color: #cc66cc;">103</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    justDoIt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  ...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>After I got over the initial shock I turned to him and asked &#8220;So why didn&#8217;t you use a for loop?&#8221; to which he replied &#8220;I would have, but the while loop came into my mind first.&#8221;</p>
<p>* Except if you are writing an extremely performance-critical application.</p>
<h3>References</h3>
<p><a name="wikipedia-branch-misprediction">[1]</a>: <a title="Wikipedia: Branch Predictor" href="http://en.wikipedia.org/wiki/Branch_predictor">Branch Predictor &#8211; Wikipedia</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=jxvxsBg0yR0:nwcd2FGjJ58:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=jxvxsBg0yR0:nwcd2FGjJ58:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=jxvxsBg0yR0:nwcd2FGjJ58:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=jxvxsBg0yR0:nwcd2FGjJ58:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=jxvxsBg0yR0:nwcd2FGjJ58:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/jxvxsBg0yR0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/codesod-how-to-avoid-the-expensive-if-statement/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/codesod-how-to-avoid-the-expensive-if-statement/</feedburner:origLink></item>
		<item>
		<title>Custom JPanel cell with JButtons in JTable</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/ogkVgRBjgCA/</link>
		<comments>http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 15:24:16 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JPanel]]></category>
		<category><![CDATA[JTable]]></category>
		<category><![CDATA[TableCellEditor]]></category>
		<category><![CDATA[TableCellRenderer]]></category>
		<category><![CDATA[TableModel]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=502</guid>
		<description><![CDATA[If you ever wanted to add a JPanel with various interactive components (e.g. JButtons, JCheckBoxes etc.) in a JTable cell and could not figure out how to make them work, then this post is for you. Otherwise, continue googling ;) The Intro It&#8217;s really difficult to find something in the Internet when you are not [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever wanted to add a JPanel with various interactive components (e.g. JButtons, JCheckBoxes etc.) in a JTable cell and could not figure out how to make them work, then this post is for you. Otherwise, continue googling ;)</p>
<p><span id="more-502"></span> </p>
<h1>The Intro</h1>
<p>It&#8217;s really difficult to find something in the Internet when you are not really sure how to phrase it. That&#8217;s why you need to practice your google-fu as much as possible. See, I was looking for a way to have a JPanel with buttons in a JTable cell, but had no idea how to look for it. <a title="Google search: JPanel in JTable" href="http://www.google.com/search?q=JPanel%20in%20JTable">JPanel in JTable</a>? <a title="Google search: JPanel with buttons in JTable" href="http://www.google.com/search?q=JPanel+with+buttons+in+JTable">JPanel with buttons in JTable</a>? <a title="Google search: JTable JPanel JButton" href="http://www.google.com/search?q=JTable+JPanel+JButton">JTable JPanel JButton</a>?</p>
<p>OK, to be fair, I&#8217;m pretty sure my answer is in there somewhere deep (as in, after the first 3 results). But, as any impatient person that respects himself, I went the easy way: StackOverflow: <a title="StackOverflow: JTable: Buttons in Custom Panel in Cell" href="http://stackoverflow.com/questions/3606864/jtable-buttons-in-custom-panel-in-cell">JTable: Buttons in Custom Panel in Cell</a>.</p>
<p>You see, most examples I found with Google talked about Cell Editors, but for simple column components, such as using a JTextField to edit an integer, or a JComboBox to edit a String etc. I wanted a custom JPanel that did not change, but simply had interactive controls.</p>
<p>In retrospect, I could have simply used a panel with MigLayout, but NO! I wanted the challenge. I wanted to learn how to do it. Plus, now I can sort my table (which is absolutely useless in my context).</p>
<p>Anyway, on with the code!</p>
<h1>The Code</h1>
<p>First thing&#8217;s first, we need to have a basic ADT that will contain some data. This is what we ultimately want to display in our table rows. Let&#8217;s say we want to have some RSS Feeds.</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeed <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> name<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> url<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> articles<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> name, <span style="color: #003399; font-weight: bold;">String</span> url, Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> articles<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> = name<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">url</span> = url<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">articles</span> = articles<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Article <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> title<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> url<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> content<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> Article<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> title, <span style="color: #003399; font-weight: bold;">String</span> url, <span style="color: #003399; font-weight: bold;">String</span> content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">title</span> = title<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">url</span> = url<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">content</span> = content<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
Yeah yeah, make the fields private, add getters/setters blah blah blah. Here is a simple JFrame that displays a JTable with some example data:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JInteractiveTableExample <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">JFrame</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> JInteractiveTableExample<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Interactive Table Cell Example&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    setDefaultCloseOperation<span style="color: #009900;">&#40;</span>EXIT_ON_CLOSE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    setSize<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span>, <span style="color: #cc66cc;">300</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">List</span><span style="color: #339933;">&lt;</span>RssFeed<span style="color: #339933;">&gt;</span> feeds = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ArrayList</span><span style="color: #339933;">&lt;</span>RssFeed<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    feeds.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pekalicious&quot;</span>, <span style="color: #0000ff;">&quot;http://feeds2.feedburner.com/pekalicious&quot;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title1&quot;</span>, <span style="color: #0000ff;">&quot;http://title1.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 1&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title2&quot;</span>, <span style="color: #0000ff;">&quot;http://title2.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 2&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title3&quot;</span>, <span style="color: #0000ff;">&quot;http://title3.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 3&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title4&quot;</span>, <span style="color: #0000ff;">&quot;http://title4.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 4&quot;</span><span style="color: #009900;">&#41;</span>,
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    feeds.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Various Thoughts on Photography&quot;</span>, <span style="color: #0000ff;">&quot;http://various-photography-thoughts.blogspot.com/feeds/posts/default&quot;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title1&quot;</span>, <span style="color: #0000ff;">&quot;http://title1.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 1&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title2&quot;</span>, <span style="color: #0000ff;">&quot;http://title2.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 2&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title3&quot;</span>, <span style="color: #0000ff;">&quot;http://title3.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 3&quot;</span><span style="color: #009900;">&#41;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> Article<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title4&quot;</span>, <span style="color: #0000ff;">&quot;http://title4.com&quot;</span>, <span style="color: #0000ff;">&quot;Content 4&quot;</span><span style="color: #009900;">&#41;</span>,
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span>
      <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> feeds.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>,
        <span style="color: #000000; font-weight: bold;">new</span> RssFeed<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> feeds.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>,
      <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;Feeds&quot;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JScrollPane</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here we create two RssFeeds with articles on the fly and add them to a JTable. If we run this example, we will see that each row displays the toString() value of our RssFeed object.</p>
<div id="attachment_504" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer.png" rel="lightbox[502]"><img class="size-medium wp-image-504 " title="jtable_without_renderer" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer-300x225.png" alt="JTable without a Cell Renderer" width="300" height="225" /></a><p class="wp-caption-text">JTable without a Cell Renderer</p></div>
<p>This is the default behavior of JTable when the data is not a known class (Strings, ints, etc.) We can change this behavior by creating a custom TableModel. Here is a basic table model for our example:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedTableModel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">AbstractTableModel</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003399; font-weight: bold;">List</span> feeds<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedTableModel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">List</span> feeds<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">feeds</span> = feeds<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Class</span> getColumnClass<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> RssFeed.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getColumnCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">String</span> getColumnName<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Feed&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getRowCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>feeds == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #cc66cc;">0</span> : feeds.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> getValueAt<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> rowIndex, <span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>feeds == <span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #006600; font-weight: bold;">null</span> : feeds.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>rowIndex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">boolean</span> isCellEditable<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex, <span style="color: #006600; font-weight: bold;">int</span> rowIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
We then simply change our table declaration to:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeedTableModel<span style="color: #009900;">&#40;</span>feeds<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Voila! We now see the exact same thing in our table!</p>
<div id="attachment_504" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer.png" rel="lightbox[502]"><img class="size-medium wp-image-504" title="jtable_without_renderer" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_without_renderer-300x225.png" alt="JTable with Table Model (but still no Cell Renderer)" width="300" height="225" /></a><p class="wp-caption-text">JTable with Table Model (but still no Cell Renderer)</p></div>
<p>Errr.. OK, so it turns out that it&#8217;s not the Model that converts our objects into Strings, but the Renderer. Each JTable has a TableCellRenderer that, given an object, it returns a Swing component that can be used to display the underlying data.</p>
<p>So now we need to tell the JTable how to convert an RssFeed into a Component. We can do this by implementing the TableCellRenderer like so:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellRenderer <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellRenderer</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellRendererComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
        <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">boolean</span> hasFocus, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">JButton</span> showButton = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;View Articles&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ActionEvent</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;HA-HA!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399; font-weight: bold;">JPanel</span> panel = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">FlowLayout</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">FlowLayout</span>.<span style="color: #006633;">LEFT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;&quot;</span> + feed.<span style="color: #006633;">name</span> + <span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span>
            + feed.<span style="color: #006633;">url</span> + <span style="color: #0000ff;">&quot;Articles &quot;</span> + feed.<span style="color: #006633;">articles</span>.<span style="color: #006633;">length</span> + <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>showButton<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSelected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000000;  font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionForeground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> panel<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
We also need to register this renderer in our table:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeedTableModel<span style="color: #009900;">&#40;</span>feeds<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setDefaultRenderer</span><span style="color: #009900;">&#40;</span>RssFeed.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellRenderer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setRowHeight</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
In the above lines, we effectively say &#8220;Whenever a column is an RssFeed class, use this renderer&#8221;. We already said that our one and only column is of type RssFeed in our table model:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Class</span> getColumnClass<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">int</span> columnIndex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">return</span> RssFeed.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now if we run our application, we can finally see something useful (although, I still prefer reading &#8220;com.pekalicious.interactiveJPanelTableCell.data.RssFeed@106caf16&#8243;. Yes, I&#8217;m THAT good):</p>
<div id="attachment_512" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_without_editor1.png" rel="lightbox[502]"><img class="size-medium wp-image-512" title="jtable_with_renderer_without_editor" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_without_editor1-300x180.png" alt="JTable with Renderer" width="300" height="180" /></a><p class="wp-caption-text">JTable with Renderer</p></div>
<p>There are two things that are wrong here: first, every time the JTable needs to render a cell, it will instantiate a new JPanel. This can harm the performance if there are many rows. Second, the button does not work! Cell renderers are used only for what they say, to render cells. They do not provide any mechanism for the underlying components. However, JTable also has Cell Editors. Cell Editors work pretty much the same way as Renderers, they take an Object and return a Component, but the component returned can be interactive.</p>
<p>As you have probably guessed already, you can have different components returned by renderers and editors. An int, for example, can be rendered using a JLabel and edited using a JTextField (which is the default behavior of JTable). However, in our example, we want the same panel both for editing and rendering. This is why we will create a common Component that will be used by both:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellComponent <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">JPanel</span> <span style="color: #009900;">&#123;</span>
  RssFeed feed<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003399; font-weight: bold;">JButton</span> showButton<span style="color: #339933;">;</span>
  <span style="color: #003399; font-weight: bold;">JLabel</span> text<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCellComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    showButton = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;View Articles&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ActionEvent</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;Reading &quot;</span> + feed.<span style="color: #006633;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    text = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    add<span style="color: #009900;">&#40;</span>showButton<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> updateData<span style="color: #009900;">&#40;</span>RssFeed feed, <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #003399; font-weight: bold;">JTable</span> table<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">feed</span> = feed<span style="color: #339933;">;</span>
&nbsp;
    text.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;&quot;</span> + feed.<span style="color: #006633;">name</span> + <span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span> + feed.<span style="color: #006633;">url</span> + <span style="color: #0000ff;">&quot;Articles &quot;</span> + feed.<span style="color: #006633;">articles</span>.<span style="color: #006633;">length</span> + <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSelected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      setBackground<span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000000;  font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
      setBackground<span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionForeground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
Now, our cell renderer becomes:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellRenderer <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellRenderer</span><span style="color: #009900;">&#123;</span>
  RssFeedCellComponent feedComponent<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCellRenderer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    feedComponent = <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellRendererComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">boolean</span> hasFocus, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
&nbsp;
    feedComponent.<span style="color: #006633;">updateData</span><span style="color: #009900;">&#40;</span>feed, isSelected, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> feedComponent<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
And once again, nothing changed! But we did optimize (and that&#8217;s always good, right?). Now, there is only one instance of  RssFeedCellComponent which changes it&#8217;s components depending on the RssFeed passed. In addition, creating a Cell Editor that returns the same component is now pretty simple:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCellEditor <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">AbstractCellEditor</span> <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellEditor</span> <span style="color: #009900;">&#123;</span>
  RssFeedCellComponent feedComponent<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCellEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    feedComponent = <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellEditorComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
    feedComponent.<span style="color: #006633;">updateData</span><span style="color: #009900;">&#40;</span>feed, <span style="color: #006600; font-weight: bold;">true</span>, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> feedComponent<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> getCellEditorValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
And now we register our editor:
</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #003399; font-weight: bold;">JTable</span> table = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JTable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RssFeedTableModel<span style="color: #009900;">&#40;</span>feeds<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setDefaultRenderer</span><span style="color: #009900;">&#40;</span>RssFeed.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellRenderer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setDefaultEditor</span><span style="color: #009900;">&#40;</span>RssFeed.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> RssFeedCellEditor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
table.<span style="color: #006633;">setRowHeight</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We can do even better. We can combine all three classes, RssFeedCellComponent, RssFeedCellRenderer and RssFeedCellEditor into a single RssFeedCell:</p>

<div class="wp_syntax"><div class="code"><pre class="java5" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RssFeedCell <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">AbstractCellEditor</span> <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399; font-weight: bold;">TableCellEditor</span>, <span style="color: #003399; font-weight: bold;">TableCellRenderer</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003399; font-weight: bold;">JPanel</span> panel<span style="color: #339933;">;</span>
  <span style="color: #003399; font-weight: bold;">JLabel</span> text<span style="color: #339933;">;</span>
  <span style="color: #003399; font-weight: bold;">JButton</span> showButton<span style="color: #339933;">;</span>
&nbsp;
  RssFeed feed<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> RssFeedCell<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    text = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;View Articles&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    showButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ActionEvent</span> arg0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399; font-weight: bold;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;Reading &quot;</span> + feed.<span style="color: #006633;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    panel = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">FlowLayout</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">FlowLayout</span>.<span style="color: #006633;">LEFT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>showButton<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #006600; font-weight: bold;">void</span> updateData<span style="color: #009900;">&#40;</span>RssFeed feed, <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #003399; font-weight: bold;">JTable</span> table<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">feed</span> = feed<span style="color: #339933;">;</span>
&nbsp;
    text.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;strong&gt;&quot;</span> + feed.<span style="color: #006633;">name</span> + <span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span> + feed.<span style="color: #006633;">url</span> + <span style="color: #0000ff;">&quot;Articles &quot;</span> + feed.<span style="color: #006633;">articles</span>.<span style="color: #006633;">length</span> + <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000;  font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isSelected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000000;  font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
      panel.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getSelectionForeground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellEditorComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
    updateData<span style="color: #009900;">&#40;</span>feed, <span style="color: #006600; font-weight: bold;">true</span>, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> panel<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> getCellEditorValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #006600; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getTableCellRendererComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">JTable</span> table, <span style="color: #003399; font-weight: bold;">Object</span> value,
      <span style="color: #006600; font-weight: bold;">boolean</span> isSelected, <span style="color: #006600; font-weight: bold;">boolean</span> hasFocus, <span style="color: #006600; font-weight: bold;">int</span> row, <span style="color: #006600; font-weight: bold;">int</span> column<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    RssFeed feed = <span style="color: #009900;">&#40;</span>RssFeed<span style="color: #009900;">&#41;</span>value<span style="color: #339933;">;</span>
    updateData<span style="color: #009900;">&#40;</span>feed, isSelected, table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> panel<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now we use only one Panel for all rendering and editing!</p>
<div id="attachment_511" class="wp-caption alignnone" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_and_editor1.png" rel="lightbox[502]"><img class="size-medium wp-image-511" title="jtable_with_renderer_and_editor" src="http://pekalicious.com/blog/wp-content/uploads/2010/08/jtable_with_renderer_and_editor1-300x179.png" alt="JTable with Renderer and Editor" width="300" height="179" /></a><p class="wp-caption-text">JTable with Renderer and Editor</p></div>
<h1>The Conclusion</h1>
<p>Every time I try to use a JTable I discover how difficult it is to just create a f*cking simple table, but I also see how powerful it is for more complex things. I&#8217;m pretty sure there is a way to display the button only on mouse over. You know, web2.0-y.</p>
<p>Anyway, that&#8217;s that. As usual, you can find the source and the executable in my <a href="http://pekalicious.com/javacorner/">Java Corner</a>.</p>
<p>Now excuse me, but I got some Void Rays to counter attack. En Taro Adun!
</pre></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=ogkVgRBjgCA:6ikmw8RGvvk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=ogkVgRBjgCA:6ikmw8RGvvk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=ogkVgRBjgCA:6ikmw8RGvvk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=ogkVgRBjgCA:6ikmw8RGvvk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=ogkVgRBjgCA:6ikmw8RGvvk:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/ogkVgRBjgCA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/custom-jpanel-cell-with-jbuttons-in-jtable/</feedburner:origLink></item>
		<item>
		<title>Microsoft Word 2007: Numbered Headings Done Right</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/RT27-tXUxYk/</link>
		<comments>http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 13:12:38 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[headings]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[numbered headings]]></category>
		<category><![CDATA[office 2007]]></category>
		<category><![CDATA[word]]></category>
		<category><![CDATA[word 2007]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=431</guid>
		<description><![CDATA[In my previous post I only briefly talked about numbering your headings. Well, today I discovered how to do them the right way. Interested? Continue reading after the jump. I was going to start with an introduction to Lists, but this needs a lot of research (about 5 minutes) so I will just reference Wikipedia [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a title="Microsoft Word 2007 Made Simple" href="http://pekalicious.com/blog/microsoft-word-made-simple/">previous</a> post I only briefly talked about numbering your headings. Well, today I discovered how to do them the right way. Interested? Continue reading after the jump.</p>
<p><span id="more-431"></span>I was going to start with an introduction to Lists, but this needs a lot of research (about 5 minutes) so I will just reference Wikipedia (which took 2 seconds):</p>
<blockquote><p>&#8220;The Bullets and Numbering system has been significantly overhauled for Office 2007, which is intended to reduce the severity of these problems.&#8221; -<a title="Microsoft Word - Wikipedia" href="http://en.wikipedia.org/wiki/Microsoft_Word#Bullets_and_numbering">Microsoft Word, Wikipedia</a></p></blockquote>
<p>I&#8217;m not pretty sure if you can modify multi level lists prior to 2007 because this is the first time I&#8217;m doing this. But anyway, in Word 2007 you have the ability to define new multi level lists styles which is VERY useful for numbering your headings.</p>
<p>Let us begin by writing some chapter and section titles. As I told you yesterday, we will first write our document and then style it. So add some old fashion Lorem Ipsum text after each title. If you are lazy like me, you will probably find this tool handy: <a title="Lorem Ipsum Generator" href="http://www.lipsum.com/">Lorem Ipsum Generator</a>. Or, use Word&#8217;s built-in command &#8220;=lorem(X)&#8221; where X is the number of paragraphs; i.e. <strong>=lorem(2)</strong>. Thank you Geri for this tip.</p>
<div id="attachment_433" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/before-heading-style.png" rel="lightbox[431]"><img class="size-medium wp-image-433" title="before-heading-style" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/before-heading-style-300x115.png" alt="Example without styles" width="300" height="115" /></a><p class="wp-caption-text">Example without styles</p></div>
<p>Once you are done with your titles, style them with the appropriate heading style. Forget about setting the numbering in the heading style. We will number them in a better way.</p>
<div id="attachment_434" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-headings.png" rel="lightbox[431]"><img class="size-medium wp-image-434" title="after-headings" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-headings-300x238.png" alt="Example with Heading styles" width="300" height="238" /></a><p class="wp-caption-text">Example with Heading styles</p></div>
<p>Now, select your first heading and click on the &#8220;Multilevel List&#8221; in the &#8220;Home&#8221; tab and choose &#8220;Define New Multilevel List&#8230;.&#8221;.</p>
<div id="attachment_435" class="wp-caption aligncenter" style="width: 205px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/define-new-multilevel.png" rel="lightbox[431]"><img class="size-medium wp-image-435" title="define-new-multilevel" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/define-new-multilevel-195x300.png" alt="Define New Multilevel List" width="195" height="300" /></a><p class="wp-caption-text">Define New Multilevel List</p></div>
<p>On the bottom left of the &#8220;Define new Multilevel list&#8221; window click on the &#8220;More &gt;&gt;&#8221; button. This is what you will see:</p>
<div id="attachment_436" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/multilevel-dialog.png" rel="lightbox[431]"><img class="size-medium wp-image-436" title="multilevel-dialog" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/multilevel-dialog-300x270.png" alt="Multilevel List Dialog" width="300" height="270" /></a><p class="wp-caption-text">Multilevel List Dialog</p></div>
<p>Here we can select a level of the list (in the top left) and change its style.</p>
<p>Let&#8217;s say you want each Heading 1 to include &#8220;Chapter&#8221;. Simply enter &#8220;Chapter&#8221; before the number in the &#8220;Enter formatting for number:&#8221; text field. I personally don&#8217;t like spacing, so I set both &#8220;Aligned at:&#8221; and &#8220;Text indent at:&#8221; to 0 cm. Finally, I prefer a single space instead of a tab before my title, so I set &#8220;Follow number with:&#8221; to Space.</p>
<p>But aside from styling your list, the important step is to link this style to your header. You do this by selecting &#8220;Heading 1&#8243; to the &#8220;Link level to style:&#8221; drop down list.</p>
<div id="attachment_437" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/link-heading-to-style.png" rel="lightbox[431]"><img class="size-medium wp-image-437" title="link-heading-to-style" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/link-heading-to-style-300x270.png" alt="Link level to style" width="300" height="270" /></a><p class="wp-caption-text">Link level to style</p></div>
<p>For levels other than 1, you can include the number of its parent level. This is very useful when you want sub sections to look like &#8220;1.2.1 Title&#8221;. Simply edit those levels and select the level you want in the &#8220;Include level number from:&#8221;. Don&#8217;t forget to link each level to the appropriate headings style.</p>
<div id="attachment_438" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/include-level-number.png" rel="lightbox[431]"><img class="size-medium wp-image-438" title="include-level-number" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/include-level-number-300x259.png" alt="Include Level Number" width="300" height="259" /></a><p class="wp-caption-text">Include Level Number</p></div>
<p>You should now have each heading numbered correctly!</p>
<div id="attachment_440" class="wp-caption aligncenter" style="width: 267px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-numbering.png" rel="lightbox[431]"><img class="size-medium wp-image-440" title="after-numbering" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/after-numbering-257x300.png" alt="After Numbering" width="257" height="300" /></a><p class="wp-caption-text">After Numbering</p></div>
<p>But what about appendices? What if you want Appendix A, Appendix B etc? Well, we know that appendices appear in the Table of Contents as the same level as Heading 1, so clearly they have to be in the first level of the list.</p>
<p>So, one way of setting this is by applying the Heading 1 style to each. Then, select your first appendix title and define a new style. The settings of the current active list style are already set, so you don&#8217;t need to set everything again. This time you have the option to select how to apply these changes. Choose &#8220;This point forward&#8221; in the &#8220;Apply changes to:&#8221; drop down list and then make your changes. Set, for instance, the &#8220;Enter formatting for number:&#8221; to Appendix and the &#8220;Number style for this level:&#8221; to &#8220;A,B,C,&#8230;&#8221; and then the &#8220;Start at:&#8221; to &#8220;A&#8221;.</p>
<div id="attachment_441" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-first-way.png" rel="lightbox[431]"><img class="size-medium wp-image-441" title="appendix-first-way" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-first-way-300x258.png" alt="Appendix Multilevel List Style" width="300" height="258" /></a><p class="wp-caption-text">Appendix Multilevel List Style</p></div>
<p>While this will do the trick, you have to manually set the new style. I hate manuals! So let&#8217;s make them autos.</p>
<p>Create a new style by opening the &#8220;Styles&#8221; windows and clicking &#8220;New Style&#8221;. Name it &#8220;Appendix&#8221;, set the &#8220;Style type:&#8221; to &#8220;Linked (paragraph and character)&#8221; and &#8220;Style for following paragraph:&#8221; to &#8220;Normal&#8221;.</p>
<p>Now, this is where the magic happens: set the &#8220;Style based on:&#8221; to &#8220;Heading 1&#8243; and click &#8220;OK&#8221;. This will link this style with Heading 1, which means two things: a) any changes in Heading 1 will be set to Appendix as well and b) the title of this heading will be set to the same level of Heading 1 in Table of Contents.</p>
<div id="attachment_442" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-style.png" rel="lightbox[431]"><img class="size-medium wp-image-442" title="appendix-style" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-style-300x224.png" alt="Appendix Style" width="300" height="224" /></a><p class="wp-caption-text">Appendix Style</p></div>
<p>If you now apply the Appendix style to your titles, you will see that &#8220;Chapter&#8221; appears before them. To set this to &#8220;Appendix&#8221;, select your title and define a new multi level list. Next, select the fourth level and set the &#8220;Link level to style:&#8221; to &#8220;Appendix&#8221;. Make any changes to the style you want (like setting &#8220;Appendix&#8221;) and your done!</p>
<div id="attachment_443" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-text.png" rel="lightbox[431]"><img class="size-medium wp-image-443" title="appendix-text" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/appendix-text-300x167.png" alt="Appendix" width="300" height="167" /></a><p class="wp-caption-text">Appendix</p></div>
<p>When you will generate your Table of Contents, you&#8217;ll see that Appendices are at the same level as Heading 1. If you change the Appendix style to be based on Heading 2, this will be visible to the Table of Contents as well.</p>
<div id="attachment_444" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-contents1.png" rel="lightbox[431]"><img class="size-medium wp-image-444" title="table-of-contents" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-contents1-300x164.png" alt="Table of Contents" width="300" height="164" /></a><p class="wp-caption-text">Table of Contents</p></div>
<p>Easy!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=RT27-tXUxYk:oMdxK2aI-7c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=RT27-tXUxYk:oMdxK2aI-7c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=RT27-tXUxYk:oMdxK2aI-7c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=RT27-tXUxYk:oMdxK2aI-7c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=RT27-tXUxYk:oMdxK2aI-7c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/RT27-tXUxYk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/</feedburner:origLink></item>
		<item>
		<title>Microsoft Word 2007 made simple</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/O2bAldrtKwU/</link>
		<comments>http://pekalicious.com/blog/microsoft-word-made-simple/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 12:48:57 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[office 2007]]></category>
		<category><![CDATA[word 2007]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=407</guid>
		<description><![CDATA[I finally figured out how to use some features in Microsoft Word 2007. Wanna join the fun? Read after the jump! Introduction Table of Contents Introduction Headers and Footers Headings References General Tips Conclusion When I need to write a formal document (like my thoughts on why my neighbors feet smell) I usually go with [...]]]></description>
			<content:encoded><![CDATA[<p>I finally figured out how to use some features in Microsoft Word 2007. Wanna join the fun? Read after the jump!</p>
<p><span id="more-407"></span></p>
<h1 id='Introduction'>Introduction</h1>
<div style="float: right; margin: 8px;"><div id='toc' class='post-407'><div id='toc_title'>Table of Contents</div>
<ul><li><a href="#Introduction">Introduction</a></li>
<li><a href="#Headers-and-Footers">Headers and Footers</a></li>
<li><a href="#Headings">Headings</a></li>
<li><a href="#References">References</a></li>
<li><a href="#General-Tips">General Tips</a></li>
<li><a href="#Conclusion">Conclusion</a></li>
</ul>
</div></div>
<p>When I need to write a formal document (like my thoughts on why my neighbors feet smell) I usually go with LaTeX. Not because the name brings interesting thoughts, but because you don&#8217;t have to deal with fancy stuff, like &#8220;What color should my title be?&#8221; or &#8220;Are the margins too narrow?&#8221;.</p>
<p>Now, don&#8217;t get me wrong, I&#8217;m all for fancy stuff. But I also get easily extracted. Hey, since when did WordPress add Ctrl+S for saving? I did it by accident (oh, you must make saving a habit, trust me) and it worked! Cool!</p>
<p>As I was saying, Microsoft Word has a lot of fancy things you can do with your plain and boring words, but they usually get on your way when you want to quickly &#8211; and I mean <strong>quickly</strong>, like, the deadline is in two hours &#8211; write your essay without adding anything. So I ended up using Word for my drafts until it was time to get serious. Then I would copy &amp; paste the text in a .tex template I have created over the years and go on from there.</p>
<p>But recently I have been a little lazy. And by recently I mean the last two years. And by two years I really mean five. The thing is, LaTeX requires a lot of energy when you want your document to be fancy. Like any other thing in the Linux world, LaTeX has a <strong>LOT </strong>of options for anything you can think of. From fancy headers to editing the space around a title. The drawback, of course, is that they aren&#8217;t in the tip of your finger, more like in a corner down at the basement of a house in the next town of the far away country. In other words, you have to find it, grab it, set it up, learn it and then you can TRY using it.</p>
<p>Just to give you an idea of the situation, <a title="LaTeX Template" href="http://pekalicious.com/blog/wp-content/uploads/2010/04/latex_template.zip">here is the template I created</a>. Every time I find something fancy I just drop it in there and see what happens. And <a title="LaTeX Template Output" href="http://pekalicious.com/blog/wp-content/uploads/2010/04/body.pdf">here is an example output</a>.</p>
<p>And to top that, LaTeX doesn&#8217;t have a standard editor. There are a couple of them lying around but each and everyone I have tried seems like it&#8217;s missing X but has Y. I mostly use <a title="TeXnicCenter" href="http://www.texniccenter.org/">TeXnicCenter</a> because it supports projects. There is also a WYSIWYG editor, which probably beats the whole idea of LaTeX in the first place, but that&#8217;s another discussion.</p>
<p>Anyway, recently I have been looking into Word with a different eye, the left one. I finally figured out how to properly use headers and footers, how referencing works, how to style my document in a consistent manner and various other neat tricks. So, before I forget them I thought of writing them down and accidentally sharing it with the world as if it was for them. Pff, silly Internet people.</p>
<p>So, without further ado, here is a list of features in Microsoft Word 2007 and how to use them.</p>
<h1 id='Headers-and-Footers'>Headers and Footers</h1>
<p>STOP right where you are! I can see you typing your name on the header. Do you know what a section is? Do you know what is &#8220;linking&#8221; between sections? Do you know what is the option &#8220;Different First Page&#8221;? <a title="Did you know I'm riding this horse backwards? - Youtube" href="http://www.youtube.com/watch?v=LpUrz9RvuPk">Do you know that I&#8217;m riding this horse backwards?</a> Well, you should.</p>
<p>Section breaks are used in Word to separate layout or formatting in a document, such as page numbering. This is essential when you have a title page, a table of contents page, a list of figures page, a list of tables page, a list of lists page, and you want them all to have different headers and footers.</p>
<p>Remember how to start a paragraph in the next page? You press 1000 times the Enter key. Or, you simply click the &#8220;Page Break&#8221; and your done. Well, a section break is similar. Only this time you go the next page AND add a new section. Section breaks can also start in the middle of the page, an even page, or in an uneven page.</p>
<p>You can do this by going to the &#8220;Page Layout&#8221; tab and clicking on the &#8220;Breaks&#8221; drop down button. You can see there are four options for entering a section.</p>
<div id="attachment_408" class="wp-caption aligncenter" style="width: 203px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/break-sections.png" rel="lightbox[407]"><img class="size-medium wp-image-408" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/break-sections-193x300.png" alt="Section Breaks" width="193" height="300" /></a><p class="wp-caption-text">Section Breaks</p></div>
<p>Let&#8217;s click the first option, &#8220;Next Page&#8221;. Just like the &#8220;Page Break&#8221; our cursor was sent to the next page and nothing else has happened. Now, either double click the top of the page or go to the &#8220;Insert&#8221; tab, click the &#8220;Header&#8221; drop down button and select any option. You will see that a contextual tab called &#8220;Design&#8221; has appeared with various options.</p>
<div id="attachment_423" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/contextual-design-tab.png" rel="lightbox[407]"><img class="size-medium wp-image-423" title="contextual-design-tab" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/contextual-design-tab-300x41.png" alt="Design Contextual Tab" width="300" height="41" /></a><p class="wp-caption-text">Design Contextual Tab</p></div>
<p>You will also see that the header now says &#8220;Header -Section 1-&#8221; or &#8220;Header -Section 2-&#8221; instead of plain &#8220;Header&#8221;.</p>
<div id="attachment_409" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/header-sections.png" rel="lightbox[407]"><img class="size-medium wp-image-409" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/header-sections-300x197.png" alt="Header Sections" width="300" height="197" /></a><p class="wp-caption-text">Header Sections</p></div>
<p>Now start typing in the header. Not anything, type &#8220;pekalicious.com&#8221;. Thank you. Now look at the header in section 2, same thing. Thank you again. But we want to have different headers for each section. So click anywhere in the section 2 header and then click on the preselected button &#8220;Link with Previous&#8221;. Nothing will happen, but if you now change it to, let&#8217;s say, &#8220;pek&#8221;, the header in section 1 will stay the same, &#8220;pekalicious.com&#8221;. Thank you once more.</p>
<div id="attachment_424" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/link-to-previews.png" rel="lightbox[407]"><img class="size-medium wp-image-424" title="link-to-previous" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/link-to-previews-300x85.png" alt="Link to Previous" width="300" height="85" /></a><p class="wp-caption-text">Link to Previous</p></div>
<p>OK, we now have separated our sections, let&#8217;s add some real content. Let&#8217;s go to the footer and try to add &#8220;Page/Total Pages&#8221;. So go to the footer and hit tab two times to go all the way to the right. You can always do this the easy and boring way: by clicking at the &#8220;Page Number&#8221; drop down list. But I like to have control.</p>
<div id="attachment_410" class="wp-caption aligncenter" style="width: 243px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/page-number.png" rel="lightbox[407]"><img class="size-medium wp-image-410" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/page-number-233x300.png" alt="Page Number" width="233" height="300" /></a><p class="wp-caption-text">Page Number Options</p></div>
<p>The way I do it is by going to the &#8220;Insert&#8221; tab, click the &#8220;Quick Parts&#8221; drop down and select &#8220;Field&#8230;&#8221;. This has a list of a lot of useful things. To insert the current page, slide down the list, select page and click &#8220;OK&#8221;. Oh, did I forgot to tell you to unlink the footer as well? Go to the footer of the first page of section 2 and unselect the &#8220;Link to Previous&#8221;. Don&#8217;t forget to delete the page number in section 1.</p>
<p>Everything seems fine until you notice that the page number in section 2 is 2 instead of 1. Well, unfortunately, you have to set the &#8220;Start at&#8230;&#8221; option. To do so, select the number, go back to the &#8220;Design&#8221; tab, click the &#8220;Page Number&#8221; drop down and select &#8220;Format Page numbers&#8230;&#8221;. Here you can set the number format, like the fancy Roman &#8220;I,II,III&#8221;, include extra information and set the &#8220;Start at&#8221;, which is what we want. So select that and enter &#8220;1&#8243;.</p>
<div id="attachment_411" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/page-number-format.png" rel="lightbox[407]"><img class="size-medium wp-image-411" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/page-number-format-300x222.png" alt="Page Number Format Options" width="300" height="222" /></a><p class="wp-caption-text">Page Number Format Options</p></div>
<p>Now let&#8217;s add a &#8220;total pages&#8221; number next to the page number. To insert this, go back to the &#8220;Field&#8230;&#8221; window and select the &#8220;SectionPages&#8221;. NOT the &#8220;NumPages&#8221;! The former will enter the total number of pages of the current section while the latter will enter the total number of pages in our document.</p>
<p>Another interesting option for the sections is the &#8220;Different First Page&#8221;, which will allow you do edit the first page of each section separately from the next. It&#8217;s kinda cool, but I find it easier to simply add another section.</p>
<h3>Summary</h3>
<p>So, for all you TL;DR people out there, here are some fancy bullet points (and by fancy I mean &#8220;plain&#8221;):</p>
<ul>
<li>Use sections to separate different styles for different pages</li>
<li>Don&#8217;t use &#8220;Link with previous&#8221; in order to separate them</li>
<li>Use section-related fields (SectionPages instead of NumPages)</li>
<li>Set the &#8220;Start at&#8230;&#8221; option to get your page number right</li>
</ul>
<h1 id='Headings'>Headings</h1>
<p>Here is what LaTeX has learned me: write first, add other shit later. In other words, leave Table of Contents, Headings and other stuff AFTER you have finished your first draft. This is important for two reasons: a) you don&#8217;t get distracted and b) you don&#8217;t get distracted. There are two levels of distraction in Word, you either try to style your document when you really have to write, or you added a style to the entire paragraph instead of a sentence and you have do undo, select carefully the words you want and style them.</p>
<p>Have you ever styled a paragraph and start writing only to discover that it has the same style? Typical in word processors. Here is a quick tip: press Ctrl+Space before you start typing the next paragraph. Voila! No styling what so ever! In fact, select any text that has some sort of formatting (like bold) and hit Ctrl+Space. Voila again!</p>
<p>Anyway, probably the most useful style is the Headings, aside from Bold, Italics and Color. Or Text Direction, Bullets and Indention. Or Font Family, Font Size and Strikethrough. Or&#8230; Anyway, Headings are important.</p>
<p>Luckily, headings DON&#8217;T continue after you have pressed enter. Cool right? Well, this can be configured for any style in that fancy box of styles up there. Even more cool is that you can have a consistent style for all your headings without selecting one by one and changing them. Just right click on any style and select &#8220;Modify&#8221;.</p>
<div id="attachment_412" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/modify-style.png" rel="lightbox[407]"><img class="size-medium wp-image-412" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/modify-style-300x111.png" alt="Modify Style" width="300" height="111" /></a><p class="wp-caption-text">Modify Style</p></div>
<p>Here you have a LOT of options. The &#8220;Style for following paragraph&#8221; will do the Enter trick. Feel free to change everything and see what happens.</p>
<p>Another important thing about the headings styles is that they are used to automatically create a table of contents. Add some Heading 1, 2 and 3 styles and then go to the &#8220;References&#8221; tab, click on the &#8220;Table of Contents&#8221; drop down and select one. Magic!</p>
<div id="attachment_413" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-contents.png" rel="lightbox[407]"><img class="size-medium wp-image-413" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-contents-300x96.png" alt="Table of Contents" width="300" height="96" /></a><p class="wp-caption-text">Table of Contents</p></div>
<p>The cool thing about the table of contents is that you don&#8217;t have to write it yourself. Every time you add a new Headings style, simply click on it and hit the &#8220;Update Table&#8221; button.</p>
<div id="attachment_414" class="wp-caption aligncenter" style="width: 248px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/update-toc.png" rel="lightbox[407]"><img class="size-full wp-image-414" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/update-toc.png" alt="Update Table of Contents" width="238" height="137" /></a><p class="wp-caption-text">Update Table of Contents</p></div>
<p>By the way, if you happen to loose a style (it doesn&#8217;t appear in the Quick Styles list on top) click on that little icon on the bottom right of the styles box to show the &#8220;Styles&#8221; window. Then click on the &#8220;Options&#8230;&#8221; on the bottom right of that window and select &#8220;All styles&#8221; in the &#8220;Select styles to show&#8221; drop down. Once you use the style it will appear again at the top. If it doesn&#8217;t, then right click on it, select &#8220;Modify&#8221; and check the &#8220;Add to Quick Style list&#8221;</p>
<div id="attachment_425" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/styles-config.png" rel="lightbox[407]"><img class="size-medium wp-image-425" title="styles-config" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/styles-config-300x225.png" alt="Add Style to Quick List" width="300" height="225" /></a><p class="wp-caption-text">Add Style to Quick List</p></div>
<p>I love this Ctrl+S feature in WordPress!</p>
<p>Among the many options you have for formatting the Headings, the one you will likely need is numbering. Especially if you are in the academics field. To add numbering go to the &#8220;Format&#8221; drop down and select&#8230; erm&#8230; &#8220;Numbering&#8221;. Here you have a variety of options, but let&#8217;s make it more interesting. Select the simple numbering &#8220;1,2,3,&#8230;&#8221; and click &#8220;Define New Number Format&#8230;&#8221;. In the &#8220;Number format:&#8221; field, before the number, enter &#8220;Chapter &#8220;. Tada! All Headings start with Chapter. You can do the same for Headings 2 and enter &#8220;Section&#8221; etc.</p>
<div id="attachment_426" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/numbered-headings.png" rel="lightbox[407]"><img class="size-medium wp-image-426" title="numbered-headings" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/numbered-headings-300x147.png" alt="Numbered Headings with Text" width="300" height="147" /></a><p class="wp-caption-text">Numbered Headings with Text</p></div>
<p>But wait, now the &#8220;Table of Contents&#8221; title says &#8220;Chapter 1. Table of Contents&#8221;. Surely we don&#8217;t want that. To fix this, simply&#8230; delete it! The next heading will automagically have the right number.</p>
<p><strong>Update</strong>: Turns out, <a title="Microsoft Word 2007: Numbered Headings Done Right - pekalicious" href="http://pekalicious.com/blog/microsoft-word-2007-numbered-headings-done-right/">there is a better way of numbering your headings</a>.</p>
<h3>Summary</h3>
<p>So, to summarize:</p>
<ul>
<li>First write, do other shit later</li>
<li>Use Headings to automatically generate Table of Contents</li>
<li>Modify the style instead of a specific heading</li>
<li>Optionally add number and text before the title</li>
</ul>
<h1 id='References'>References</h1>
<p>One of the best things in LaTeX is its simplicity of adding citations: just add &#8220;\cite{Name_of_Citation}&#8221; which you have already defined in a Bibtex file in the Bibtex format, insert it into your main document, compile twice and your done. OK, maybe I have done this 23098420938 times, but still, this will add a fancy &#8220;Bibliography&#8221; at the end of your document with correct numbering and format (APA, IEEE etc). There is also this amazing tool, <a title="JabRef" href="http://jabref.sourceforge.net/">JabRef</a>, that will help you.</p>
<p>Let&#8217;s do the same fancy thing in Word. First of all, you need to decide what style you will be using. If it&#8217;s APA, your OK, but if you are unlucky like me, it&#8217;s definitely IEEE. This is not included in 2007, but you can download it <a title="IEEE Citation Style for Word 2007 - Bibword" href="http://bibword.codeplex.com/releases/view/15365">here</a>. Copy the file in the %programfiles%\Microsoft Office\Office12\Bibliography\Style directory and restart Word. You should now see the IEEE in the drop down in the &#8220;References&#8221; tab.</p>
<div id="attachment_415" class="wp-caption aligncenter" style="width: 300px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/ieee-style.png" rel="lightbox[407]"><img class="size-full wp-image-415" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/ieee-style.png" alt="IEEE Reference Style" width="290" height="244" /></a><p class="wp-caption-text">IEEE Reference Style</p></div>
<p>Let&#8217;s add some sources: click on &#8220;Manages Sources&#8221; and add some books. Good thing there is a Master List, this will save you in the long run.</p>
<div id="attachment_416" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/source-manager.png" rel="lightbox[407]"><img class="size-medium wp-image-416" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/source-manager-300x205.png" alt="Source Manager" width="300" height="205" /></a><p class="wp-caption-text">Source Manager</p></div>
<p>Go at the end of any word, click the &#8220;Insert Citation&#8221; drop down and select your book. That&#8217;s it!</p>
<div id="attachment_417" class="wp-caption aligncenter" style="width: 205px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/insert-citation.png" rel="lightbox[407]"><img class="size-full wp-image-417" title="insert-citation" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/insert-citation.png" alt="Insert Citation Menu" width="195" height="294" /></a><p class="wp-caption-text">Insert Citation Menu</p></div>
<p>If you use APA, you will see &#8220;(pek, My Boring Book, 2010)&#8221; or, if you use IEEE, you will see just a boring &#8220;[1]&#8220;. To create the bibliography at the end of your document, just click on the &#8220;Bibliography&#8221; drop down and select the style you want. This works the same way as Table of Contents, so if you see &#8220;Chapter X&#8221; simply delete it.</p>
<div id="attachment_418" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/bibliography.png" rel="lightbox[407]"><img class="size-medium wp-image-418" title="bibliography" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/bibliography-300x123.png" alt="Bibliography" width="300" height="123" /></a><p class="wp-caption-text">Bibliography</p></div>
<p>That was easy. Even easier are footnotes. Just click on the &#8220;Add Footnote&#8221; button and enter your text.</p>
<div id="attachment_419" class="wp-caption aligncenter" style="width: 266px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/footnote.png" rel="lightbox[407]"><img class="size-medium wp-image-419" title="footnote" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/footnote-256x300.png" alt="Footnote" width="256" height="300" /></a><p class="wp-caption-text">Footnote</p></div>
<p>To create the list of figures, you must insert captions. Not the ones where you try to position the text under an image and call it a caption, I mean real captions, as in, select the image, go to the &#8220;References&#8221; tab and click &#8220;Insert Caption&#8221;. Once you have done that to a couple of images, insert anywhere you want in the top of page 3 the table of figures by clicking &#8220;Insert Table of Figures&#8221;. Again, works the same way. Make sure not to delete the number that is automatically added, otherwise it will not show up in the Table of Figures.</p>
<div id="attachment_420" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-figures.png" rel="lightbox[407]"><img class="size-medium wp-image-420" title="table-of-figures" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/table-of-figures-300x191.png" alt="Table of figures" width="300" height="191" /></a><p class="wp-caption-text">Table of figures</p></div>
<p>To cross-reference a section, a figure, a table, or any text, go anywhere and click &#8220;Cross-reference&#8221;. There are many options there, but I will focus on bookmarks. You can bookmark anything in a Word document by simply selecting it and clicking the &#8220;Bookmark&#8221; button in the &#8220;Insert&#8221; tab. Just enter the name of the bookmark and click &#8220;Add&#8221;. To cross-reference this select &#8220;Bookmark&#8221; in the &#8220;Reference Type&#8221; and then chose what to reference to in the &#8220;Insert reference to&#8221; drop down.</p>
<div id="attachment_421" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/bookmark.png" rel="lightbox[407]"><img class="size-medium wp-image-421" title="bookmark" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/bookmark-300x119.png" alt="Bookmark" width="300" height="119" /></a><p class="wp-caption-text">Bookmark</p></div>
<p>Finally, we can create an Index page that lists all of our important words, like Donkey. Select a word or phrase, click on the &#8220;Mark Entry&#8221; in the &#8220;Reference&#8221; tab and then click &#8220;Mark&#8221; in the . This will add some gibberish next to the word and also show all kinds of stuff. These stuff can be hidden again by clicking the &#8220;Show/Hide Marks&#8221; in the &#8220;Home&#8221; tab. Once you are done creating all your entries, create the index page by clicking &#8220;Insert Index&#8221; in the &#8220;Reference&#8221; tab.</p>
<div id="attachment_427" class="wp-caption aligncenter" style="width: 310px"><a href="http://pekalicious.com/blog/wp-content/uploads/2010/04/index.png" rel="lightbox[407]"><img class="size-medium wp-image-427" title="index" src="http://pekalicious.com/blog/wp-content/uploads/2010/04/index-300x110.png" alt="Index" width="300" height="110" /></a><p class="wp-caption-text">Index</p></div>
<p>Have I mentioned how much I love WordPress&#8217; Ctrl+S?</p>
<h3>Summary</h3>
<p>That&#8217;s it for the references. Pretty simple I think. And here are your bullets:</p>
<ul>
<li>Citations, Table of figures and Index can all be created automatically</li>
<li>Use the &#8220;Insert Caption&#8221; instead of manually adding text under your image</li>
<li>Use &#8220;Bookmarks&#8221; to cross-reference anything in your document</li>
</ul>
<h1 id='General-Tips'>General Tips</h1>
<p>SAVE. SAVE SAVE SAVE SAVE. I can&#8217;t emphasize this enough. Make Ctrl+S a habit. And I&#8217;m not just talking about Microsoft Word; PowerPoint, notepad, trees, everything. Just save whenever you stop for more than 2 seconds.</p>
<p>First type and then style. Even when you want to bold a text. You will avoid &#8220;bolding&#8221; a lot of things. Just remember, in case of panic, use Ctrl+Space.</p>
<p>Use comments under the &#8220;Review&#8221; tab to remember things. Comments catch your eye easier than underlining a sentence.</p>
<h1 id='Conclusion'>Conclusion</h1>
<p>After finally figuring out the sections and citations, I started appreciating Word more. Of course, I still prefer LaTeX for my &#8220;serious&#8221; documents (see Cook Book), but now I can use Word for more than just drafts. And these are only the basics. I have yet to discover what this &#8220;Mailings&#8221; tab is or how to properly use the &#8220;Equation&#8221;.</p>
<p>Have fun.</p>
<p>And save.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=O2bAldrtKwU:1tNOwbRCJkY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=O2bAldrtKwU:1tNOwbRCJkY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=O2bAldrtKwU:1tNOwbRCJkY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=O2bAldrtKwU:1tNOwbRCJkY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=O2bAldrtKwU:1tNOwbRCJkY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/O2bAldrtKwU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/microsoft-word-made-simple/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/microsoft-word-made-simple/</feedburner:origLink></item>
		<item>
		<title>Introducing ‘JSpriteSheetCreator’</title>
		<link>http://feedproxy.google.com/~r/pekalicious/~3/_iLNX2v0ZbI/</link>
		<comments>http://pekalicious.com/blog/introducing-jspritesheetcreator/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 18:48:51 +0000</pubDate>
		<dc:creator>Panagiotis Peikidis</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[game programming]]></category>

		<guid isPermaLink="false">http://pekalicious.com/blog/?p=392</guid>
		<description><![CDATA[One of the first things you will need when developing a 2D game will be a sprite class. This sprite class will eventually need to handle animations. So what do you do? As any prototyping tool you develop, you go look for free graphic resources. Unfortunately, most animated sprites are in a gif format. So [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first things you will need when developing a 2D game will be a sprite class. This sprite class will eventually need to handle animations. So what do you do? As any prototyping tool you develop, you go look for free graphic resources. Unfortunately, most animated sprites are in a gif format. So now you need something that will convert that into a single sprite sheet. Here is where JSpriteSheetCreator comes.</p>
<p><span id="more-392"></span></p>
<p>Either my google-fu isn&#8217;t what it used to or a demand for such an utility isn&#8217;t what I had imagined. I&#8217;m talking about a small application that will take an animated gif file and turn it into a single sprite sheet. Let me rephrase that to make it a little more clear: JSpriteSheetCreator will convert a file <span style="text-decoration: underline;"><strong>FROM</strong></span> an <span style="text-decoration: underline;">animated gif</span> <span style="color: #ff0000;"><span style="text-decoration: underline;"><strong>TO</strong></span></span> a <span style="text-decoration: underline;">single png sprite sheet</span>.</p>
<p>Yeah&#8230; I repeat that because searching for &#8220;<a href="http://www.google.com/search?q=convert+gif+to+single+sprite+sheet">convert gif to single sprite sheet</a>&#8221; or &#8220;<a href="http://www.google.com/search?q=from+gif+&quot;to+sprite+sheet&quot;">from gif &#8220;to sprite sheet&#8221;</a>&#8221; or &#8220;<a href="http://www.google.com/search?q=sprite+sheet+converter">sprite sheet converter</a>&#8221; or &#8220;<a href="http://www.google.com/search?q=FOR+GOD+SAKES+I+NEED+TO+CONVERT+A+GIF+TO+A+PNG">&lt;other search you think will work&gt;</a>&#8221; and any other combination of words I looked for didn&#8217;t work. Google kept returning from sprite sheet to gif. Which is kind of weird because, as I see it, in games, you have better control of the animation with a sprite sheet than a gif. On the other hand, making an animated gif is probably useful for many other reasons.</p>
<p>Anyway, the only application that I finally found was <a title="Avi4BMP" href="http://www.bottomap.com/Software/A4B/A4B.html">Avi4Bmp</a>. Which does the basic job of converting from an animated gif to a png and vise versa pretty good. But I have more ideas for such a tool.</p>
<p>Initially, JSpriteSheetCreator will do just that. But in my next iteration I will add support for reordering the frames and of course import/export <a href="http://www.ziggyware.com/readarticle.php?article_id=138">xml animation data</a> (<strong>WARNING</strong>: as of this time, google will tell you that ziggyware is an attack site. <a href="http://forums.xna.com/forums/p/40420/236290.aspx">They are probably hacked</a> so make sure you know what you are doing i.e. use <a href="https://addons.mozilla.org/en-US/firefox/addon/1865">AdBlock</a> and/or <a href="https://addons.mozilla.org/en-US/firefox/addon/722">NoScript</a>) that will help integrate this into a game developers workflow.</p>
<p>As any other utility I develop, I am hosting this in my own server. You can find it under my <a href="http://pekalicious.com/javacorner">Java Corner</a>. You can even run it without downloading it with Web Start (provided you trust me). You can also find the source code.</p>
<p>Of course, I would like to thank Kevin Weiner for his ultra slim <a href="http://www.fmsware.com/stuff/gif.html">GifDecoder</a> class.</p>
<p>Enjoy!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/pekalicious?a=_iLNX2v0ZbI:mDKrveTrsXI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=_iLNX2v0ZbI:mDKrveTrsXI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=_iLNX2v0ZbI:mDKrveTrsXI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/pekalicious?i=_iLNX2v0ZbI:mDKrveTrsXI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/pekalicious?a=_iLNX2v0ZbI:mDKrveTrsXI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/pekalicious?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/pekalicious/~4/_iLNX2v0ZbI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://pekalicious.com/blog/introducing-jspritesheetcreator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://pekalicious.com/blog/introducing-jspritesheetcreator/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 6.066 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-05-18 18:22:52 -->

