<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Exploding Pixels &#187; Uncategorized</title>
	<atom:link href="http://explodingpixels.wordpress.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://explodingpixels.wordpress.com</link>
	<description>Exposing the pixels behind beautiful user interfaces</description>
	<lastBuildDate>Mon, 14 Dec 2009 12:19:58 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='explodingpixels.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/93de78cc5deb87575613a8e50dd5d593?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Exploding Pixels &#187; Uncategorized</title>
		<link>http://explodingpixels.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://explodingpixels.wordpress.com/osd.xml" title="Exploding Pixels" />
		<item>
		<title>Working around BasicTableUI&#8217;s lack of a prepareRenderer hook</title>
		<link>http://explodingpixels.wordpress.com/2009/06/27/working-around-basictableuis-lack-of-a-preparerenderer-hook/</link>
		<comments>http://explodingpixels.wordpress.com/2009/06/27/working-around-basictableuis-lack-of-a-preparerenderer-hook/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 21:46:46 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=1076</guid>
		<description><![CDATA[If you&#8217;ve ever extended BasicTableUI, you may have struggled a bit with it&#8217;s inability to hook into the cell rendering process. JTable has the prepareRenderer method through which you can inject yourself into the cell painting pipeline. BasicTableUI, however, has no such mechanism.
Why would we even need this capability from a BasicTableUI? In ITunesTableUI, for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=explodingpixels.wordpress.com&blog=3555046&post=1076&subd=explodingpixels&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>If you&#8217;ve ever extended <tt>BasicTableUI</tt>, you may have struggled a bit with it&#8217;s inability to hook into the cell rendering process. <tt>JTable</tt> has the <tt>prepareRenderer</tt> method through which you can inject yourself into the cell painting pipeline. <tt>BasicTableUI</tt>, however, has no such mechanism.</p>
<p>Why would we even need this capability from a <tt>BasicTableUI</tt>? In <tt><a href="http://code.google.com/p/macwidgets/source/browse/trunk/source/com/explodingpixels/macwidgets/plaf/ITunesTableUI.java">ITunesTableUI</a></tt>, for example, I install a special border on the containing <tt>JScrollPane</tt>, which paints the row striping (the subject of a future blog entry). In order for the striping to show through, each renderer must be non-opaque (transparent). By default, renderers are opaque, which results in a table that looks like this:</p>
<p><a href="http://explodingpixels.files.wordpress.com/2009/06/itunestable-bad1.png"><img src="http://explodingpixels.files.wordpress.com/2009/06/itunestable-bad1.png?w=355&#038;h=205" alt="iTunesTable-bad" title="iTunesTable-bad" width="355" height="205" class="aligncenter size-full wp-image-1088" /></a><br />
We have a couple of options to work around this. First, we could simply grab each of the default renderers and make it non-opaque. This isn&#8217;t a great solution, though, because there&#8217;s no easy way to get a list of all these renderers &#8212; we&#8217;d end up harding coding a set into our UI delegate. And if downstream consumers added their own renderers, they&#8217;d be responsible for making sure they were non-opaque.</p>
<p>The second (and better) option, is to create a custom <tt>CellRendererPane</tt> that essentially gives us a <tt>prepareRenderer</tt> method. <tt>CellRendererPane</tt> is the class used to stamp out each table cell onto the screen. The renderer for the cell is prepared, and then added to the <tt>CellRendererPane</tt>, which manually invokes <tt>paintComponent</tt>. Overriding <tt>paintComponent</tt> gives us the hook into the cell painting process that we&#8217;re looking for. Here&#8217;s what the custom <tt>CellRendererPane</tt> looks like:</p>
<pre>
    /**
     * Creates a custom {@link CellRendererPane} that sets the renderer component to
     * be non-opaque if the associated row isn't selected. This custom
     * {@code CellRendererPane} is needed because a table UI delegate has no prepare
     * renderer like {@link JTable} has.
     */
    private CellRendererPane createCustomCellRendererPane() {
        return new CellRendererPane() {
            @Override
            public void paintComponent(Graphics graphics, Component component,
                                       Container container, int x, int y, int w, int h,
                                       boolean shouldValidate) {
                // figure out what row we're rendering a cell for.
                int rowAtPoint = table.rowAtPoint(new Point(x, y));
                boolean isSelected = table.isRowSelected(rowAtPoint);
                // if the component to render is a JComponent, add our tweaks.
                if (component instanceof JComponent) {
                    JComponent jcomponent = (JComponent) component;
                    jcomponent.setOpaque(isSelected);
                }

                super.paintComponent(graphics, component, container, x, y, w, h,
                    shouldValidate);
            }
        };
    }
</pre>
<p>Here&#8217;s how we create and install this custom <tt>CellRendererPane</tt> in our extension of <tt>BasicTableUI</tt>:</p>
<pre>
CustomTableUI extends BasicTableUI {
    // ...
    @Override
    public void installUI(JComponent c) {
        super.installUI(c);

        table.remove(rendererPane);
        rendererPane = createCustomCellRendererPane();
        table.add(rendererPane);

        // ...
    }
}
</pre>
<p>and that lets us make all our non-selected cells non-opaque!</p>
<p><a href="http://explodingpixels.files.wordpress.com/2009/06/itunestable-good1.png"><img src="http://explodingpixels.files.wordpress.com/2009/06/itunestable-good1.png?w=355&#038;h=205" alt="iTunesTable-good" title="iTunesTable-good" width="355" height="205" class="aligncenter size-full wp-image-1087" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/explodingpixels.wordpress.com/1076/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/explodingpixels.wordpress.com/1076/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/explodingpixels.wordpress.com/1076/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/explodingpixels.wordpress.com/1076/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/explodingpixels.wordpress.com/1076/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/explodingpixels.wordpress.com/1076/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/explodingpixels.wordpress.com/1076/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/explodingpixels.wordpress.com/1076/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/explodingpixels.wordpress.com/1076/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/explodingpixels.wordpress.com/1076/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=explodingpixels.wordpress.com&blog=3555046&post=1076&subd=explodingpixels&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://explodingpixels.wordpress.com/2009/06/27/working-around-basictableuis-lack-of-a-preparerenderer-hook/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bac4c05b46a66b8cc91a638abd8ccceb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ken</media:title>
		</media:content>

		<media:content url="http://explodingpixels.files.wordpress.com/2009/06/itunestable-bad1.png" medium="image">
			<media:title type="html">iTunesTable-bad</media:title>
		</media:content>

		<media:content url="http://explodingpixels.files.wordpress.com/2009/06/itunestable-good1.png" medium="image">
			<media:title type="html">iTunesTable-good</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhone to the rescue</title>
		<link>http://explodingpixels.wordpress.com/2008/12/22/iphone-to-the-rescue/</link>
		<comments>http://explodingpixels.wordpress.com/2008/12/22/iphone-to-the-rescue/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 13:12:19 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=483</guid>
		<description><![CDATA[
I was one of the poor saps in southern New Hampshire who lost his power in the recent ice storm &#8211; me and 430,000 NH residents! Not only did I lose my power, but it wasn&#8217;t restored for a week &#8211; that&#8217;s a painfully long time to be disconnected. 
Fortunately for me, I could stay [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=explodingpixels.wordpress.com&blog=3555046&post=483&subd=explodingpixels&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://explodingpixels.files.wordpress.com/2008/12/no_power1.png"><img src="http://explodingpixels.files.wordpress.com/2008/12/no_power1.png?w=478&#038;h=161" alt="no_power1" title="no_power1" width="478" height="161" class="aligncenter size-full wp-image-491" /></a><br />
I was one of the poor saps in southern New Hampshire who lost his power in the <a href="http://www.msnbc.msn.com/id/28237859/">recent ice storm</a> &#8211; me and 430,000 NH residents! Not only did I lose my power, but it wasn&#8217;t restored for a week &#8211; that&#8217;s a painfully long time to be disconnected. </p>
<p>Fortunately for me, I could stay connected with my relatively new and shiny iPhone. I think I would have gone stir crazy without it. This unusual event made the $70 monthly fee seem oh-so worth it!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/explodingpixels.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/explodingpixels.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/explodingpixels.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/explodingpixels.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/explodingpixels.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/explodingpixels.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/explodingpixels.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/explodingpixels.wordpress.com/483/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/explodingpixels.wordpress.com/483/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/explodingpixels.wordpress.com/483/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=explodingpixels.wordpress.com&blog=3555046&post=483&subd=explodingpixels&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://explodingpixels.wordpress.com/2008/12/22/iphone-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bac4c05b46a66b8cc91a638abd8ccceb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ken</media:title>
		</media:content>

		<media:content url="http://explodingpixels.files.wordpress.com/2008/12/no_power1.png" medium="image">
			<media:title type="html">no_power1</media:title>
		</media:content>
	</item>
		<item>
		<title>Yet another blog</title>
		<link>http://explodingpixels.wordpress.com/2008/04/22/yet-another-blog/</link>
		<comments>http://explodingpixels.wordpress.com/2008/04/22/yet-another-blog/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 22:05:18 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=3</guid>
		<description><![CDATA[At the risk of being left completely in the 20th century, I&#8217;ve finally broken down and started a blog. Mainly because I want a place to post sample code and screen shots from my upcoming Java One presentation (Simply Sweet Apps with Glazed Lists).
Other than for my immediate content sharing needs, you&#8217;ll probably find sexy UI stuff [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=explodingpixels.wordpress.com&blog=3555046&post=3&subd=explodingpixels&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>At the risk of being left completely in the 20th century, I&#8217;ve finally broken down and started a blog. Mainly because I want a place to post sample code and screen shots from my upcoming Java One presentation (<a href="https://www28.cplan.com/cc191/session_details.jsp?isid=296047&amp;ilocation_id=191-1&amp;ilanguage=english" target="_blank">Simply Sweet Apps with Glazed Lists</a>).</p>
<p>Other than for my immediate content sharing needs, you&#8217;ll probably find sexy UI stuff here, mostly in Java &#8211; so if your into that kinda thing, stay tuned.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/explodingpixels.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/explodingpixels.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/explodingpixels.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/explodingpixels.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/explodingpixels.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/explodingpixels.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/explodingpixels.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/explodingpixels.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/explodingpixels.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/explodingpixels.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/explodingpixels.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/explodingpixels.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=explodingpixels.wordpress.com&blog=3555046&post=3&subd=explodingpixels&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://explodingpixels.wordpress.com/2008/04/22/yet-another-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/bac4c05b46a66b8cc91a638abd8ccceb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Ken</media:title>
		</media:content>
	</item>
	</channel>
</rss>