<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: JTable setRowHeight causes slow repainting</title>
	<atom:link href="http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/</link>
	<description>Software Development - random theories, code snippits and opinions</description>
	<lastBuildDate>Tue, 18 Oct 2011 23:30:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nick</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-25333</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Tue, 18 Oct 2011 23:30:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-25333</guid>
		<description>Hi the TimingRepaintManager is actually a very simple inner class in the test code linked to the original blog post, replicated again below

It&#039;s very possible to write a similar class which times painting for JTable component specifically rather than all repainting - and indeed since we have had a lot of table painting performance issues in the past, we have written a repaint manager which throttles painting for all JTables, letting the other repaints go through unthrottled. That&#039;s worthy of another post in its own right, if I can get time to write it. RepaintManager is quite a powerful class, and can be customised.

&lt;code&gt;
//record the total time spent repainting
    private static class TimingRepaintManager extends RepaintManager {
        private volatile long totalTime;

        public void paintDirtyRegions() {
            long startTime = System.currentTimeMillis();
            super.paintDirtyRegions();
            totalTime += System.currentTimeMillis() - startTime;
        }

        public long getTotalRepaintTime() {
            return totalTime;
        }

        public void resetTotalRepaintTime() {
            this.totalTime = 0;
        }
    }

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi the TimingRepaintManager is actually a very simple inner class in the test code linked to the original blog post, replicated again below</p>
<p>It&#8217;s very possible to write a similar class which times painting for JTable component specifically rather than all repainting &#8211; and indeed since we have had a lot of table painting performance issues in the past, we have written a repaint manager which throttles painting for all JTables, letting the other repaints go through unthrottled. That&#8217;s worthy of another post in its own right, if I can get time to write it. RepaintManager is quite a powerful class, and can be customised.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:735px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">//record the total time spent repainting<br />
&nbsp; &nbsp; private static class TimingRepaintManager extends RepaintManager {<br />
&nbsp; &nbsp; &nbsp; &nbsp; private volatile long totalTime;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public void paintDirtyRegions() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; long startTime = System.currentTimeMillis();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super.paintDirtyRegions();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totalTime += System.currentTimeMillis() - startTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public long getTotalRepaintTime() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return totalTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public void resetTotalRepaintTime() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.totalTime = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }</div></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ole</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-25328</link>
		<dc:creator>Ole</dc:creator>
		<pubDate>Tue, 18 Oct 2011 22:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-25328</guid>
		<description>Thanks for your interesting article. Can you elaborate a bit more on this TimingRepaintManager of yours? Is the source code available? Thanks a lot.</description>
		<content:encoded><![CDATA[<p>Thanks for your interesting article. Can you elaborate a bit more on this TimingRepaintManager of yours? Is the source code available? Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-4618</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Thu, 17 Dec 2009 14:43:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-4618</guid>
		<description>Thanks Dave, I&#039;ll check that out later</description>
		<content:encoded><![CDATA[<p>Thanks Dave, I&#8217;ll check that out later</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-4616</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 17 Dec 2009 14:33:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-4616</guid>
		<description>I tried your workaround and it vastly improved performance but caused some repainting issues. I believe the calculation of the y coordinate for the dirty region is sometimes incorrect ( because it isn&#039;t adjusted like the height is)

I&#039;ve changed this:
dirtyRegion = new Rectangle(0, start * getRowHeight(),getColumnModel().getTotalColumnWidth(), 0);

To this:
int rowStart = 0;
for ( int row=0; row &lt; start; row++ ) {
    rowStart += getRowHeight(row);
}
dirtyRegion = new Rectangle(0, rowStart, getColumnModel().getTotalColumnWidth(), 0);

Would be interested to hear if you agree or not.</description>
		<content:encoded><![CDATA[<p>I tried your workaround and it vastly improved performance but caused some repainting issues. I believe the calculation of the y coordinate for the dirty region is sometimes incorrect ( because it isn&#8217;t adjusted like the height is)</p>
<p>I&#8217;ve changed this:<br />
dirtyRegion = new Rectangle(0, start * getRowHeight(),getColumnModel().getTotalColumnWidth(), 0);</p>
<p>To this:<br />
int rowStart = 0;<br />
for ( int row=0; row &lt; start; row++ ) {<br />
    rowStart += getRowHeight(row);<br />
}<br />
dirtyRegion = new Rectangle(0, rowStart, getColumnModel().getTotalColumnWidth(), 0);</p>
<p>Would be interested to hear if you agree or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-4614</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 17 Dec 2009 13:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-4614</guid>
		<description>Thanks Nick. Yes I have seen the same issue. I think it is a big problem, especially if the data in your table is frequently updated. Please could you update the post if your hear anything from Sun?</description>
		<content:encoded><![CDATA[<p>Thanks Nick. Yes I have seen the same issue. I think it is a big problem, especially if the data in your table is frequently updated. Please could you update the post if your hear anything from Sun?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-4536</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Fri, 11 Dec 2009 15:22:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-4536</guid>
		<description>Hi Dave

I submitted the report etc. but never received anything back from Sun...  you don&#039;t get a bug id until they process it but it was a long time ago now. Perhaps I should try submitting it again. Have you seen this problem too?

Nick</description>
		<content:encoded><![CDATA[<p>Hi Dave</p>
<p>I submitted the report etc. but never received anything back from Sun&#8230;  you don&#8217;t get a bug id until they process it but it was a long time ago now. Perhaps I should try submitting it again. Have you seen this problem too?</p>
<p>Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/comment-page-1/#comment-4533</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 11 Dec 2009 13:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.objectdefinitions.com/odblog/?p=234#comment-4533</guid>
		<description>Thanks for the post Nick. What is the status of the bug report you submitted to sun? Do you have a link to it?</description>
		<content:encoded><![CDATA[<p>Thanks for the post Nick. What is the status of the bug report you submitted to sun? Do you have a link to it?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

