<?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/"
	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>Comments on: Making a JTable fill the view without extension</title>
	<atom:link href="http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/feed/" rel="self" type="application/rss+xml" />
	<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/</link>
	<description>Exposing the pixels behind beautiful user interfaces</description>
	<lastBuildDate>Thu, 10 Dec 2009 16:18:30 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Thomas Singer</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-245</link>
		<dc:creator>Thomas Singer</dc:creator>
		<pubDate>Sun, 12 Oct 2008 09:05:48 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-245</guid>
		<description>Unfortunately, the suggestion to overwrite getScrollableTracksViewportHeight() does not work with Quaqua 5. :(</description>
		<content:encoded><![CDATA[<p>Unfortunately, the suggestion to overwrite getScrollableTracksViewportHeight() does not work with Quaqua 5. :(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-236</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Tue, 07 Oct 2008 12:17:19 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-236</guid>
		<description>Hi Aekold,

I mentioned in the opening paragraph that this problem is a non-issue in JDK 6. Those of us still using JDK 5, though, need a solution!

-Ken</description>
		<content:encoded><![CDATA[<p>Hi Aekold,</p>
<p>I mentioned in the opening paragraph that this problem is a non-issue in JDK 6. Those of us still using JDK 5, though, need a solution!</p>
<p>-Ken</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-235</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Tue, 07 Oct 2008 12:15:20 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-235</guid>
		<description>Hi rbs,

Your absolutely right - the grid lines don&#039;t paint the entire viewport (one of the reasons I hid them!). Unfortunately, the BasicTableUI.paintGrid method is private, which makes fixing this issue just a little bit harder. Here is a method that you could stick in the table UI delegate I provided that would paint the missing grid lines:

private void paintEmptyRowGridLines(Graphics g) {
        Graphics newGraphics = g.create();

        // grab the y coordinate of the top of the first non-existent row (also
        // can be thought of as the bottom of the last row).
        int firstNonExistentRowY = getRowCount() * getRowHeight();

        // only paint the region within the clipp bounds.
        Rectangle clip = newGraphics.getClipBounds();
       
        // paint the column grid dividers for the non-existent rows.
        int x = 0;
        for (int i = 0; i &lt; getColumnCount(); i++) {
            TableColumn column = getColumnModel().getColumn(i);
            // increase the x position by the width of the current column.
            x += column.getWidth();
            newGraphics.setColor(table.getGridColor());
            // draw the grid line (not sure what the -1 is for, but BasicTableUI
            // also does it.
            newGraphics.drawLine(x - 1, firstNonExistentRowY, x - 1, getHeight());
        }

        newGraphics.dispose();
    }</description>
		<content:encoded><![CDATA[<p>Hi rbs,</p>
<p>Your absolutely right &#8211; the grid lines don&#8217;t paint the entire viewport (one of the reasons I hid them!). Unfortunately, the BasicTableUI.paintGrid method is private, which makes fixing this issue just a little bit harder. Here is a method that you could stick in the table UI delegate I provided that would paint the missing grid lines:</p>
<p>private void paintEmptyRowGridLines(Graphics g) {<br />
        Graphics newGraphics = g.create();</p>
<p>        // grab the y coordinate of the top of the first non-existent row (also<br />
        // can be thought of as the bottom of the last row).<br />
        int firstNonExistentRowY = getRowCount() * getRowHeight();</p>
<p>        // only paint the region within the clipp bounds.<br />
        Rectangle clip = newGraphics.getClipBounds();</p>
<p>        // paint the column grid dividers for the non-existent rows.<br />
        int x = 0;<br />
        for (int i = 0; i &lt; getColumnCount(); i++) {<br />
            TableColumn column = getColumnModel().getColumn(i);<br />
            // increase the x position by the width of the current column.<br />
            x += column.getWidth();<br />
            newGraphics.setColor(table.getGridColor());<br />
            // draw the grid line (not sure what the -1 is for, but BasicTableUI<br />
            // also does it.<br />
            newGraphics.drawLine(x &#8211; 1, firstNonExistentRowY, x &#8211; 1, getHeight());<br />
        }</p>
<p>        newGraphics.dispose();<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aekold</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-234</link>
		<dc:creator>Aekold</dc:creator>
		<pubDate>Tue, 07 Oct 2008 09:04:06 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-234</guid>
		<description>http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html#setFillsViewportHeight(boolean)
This method does all the job for Java 6. Internal it may be the same way, but it is much better, than custom UI delegates...</description>
		<content:encoded><![CDATA[<p><a href="http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html#setFillsViewportHeight(boolean)" rel="nofollow">http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html#setFillsViewportHeight(boolean)</a><br />
This method does all the job for Java 6. Internal it may be the same way, but it is much better, than custom UI delegates&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rbs</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-233</link>
		<dc:creator>rbs</dc:creator>
		<pubDate>Tue, 07 Oct 2008 02:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-233</guid>
		<description>Ken,

Although this looks like an elegant solution to the &quot;empty rows problem&quot;, one area where it seems to fail is painting of any gridlines which might have been specified.</description>
		<content:encoded><![CDATA[<p>Ken,</p>
<p>Although this looks like an elegant solution to the &#8220;empty rows problem&#8221;, one area where it seems to fail is painting of any gridlines which might have been specified.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bitguru</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-232</link>
		<dc:creator>bitguru</dc:creator>
		<pubDate>Mon, 06 Oct 2008 18:49:42 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-232</guid>
		<description>hey Ken,

No, I understand those limitations. I mentioned setting the viewport&#039;s background color only because it&#039;s a quick-and-easy solution for some people&#039;s needs. When I had needed to support DnD drops in the past, I had to use better fixes.

btw, if you want to see a different JViewPort hack, see http://bitguru.wordpress.com/2008/01/07/lazyviewport/</description>
		<content:encoded><![CDATA[<p>hey Ken,</p>
<p>No, I understand those limitations. I mentioned setting the viewport&#8217;s background color only because it&#8217;s a quick-and-easy solution for some people&#8217;s needs. When I had needed to support DnD drops in the past, I had to use better fixes.</p>
<p>btw, if you want to see a different JViewPort hack, see <a href="http://bitguru.wordpress.com/2008/01/07/lazyviewport/" rel="nofollow">http://bitguru.wordpress.com/2008/01/07/lazyviewport/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swing links of the week: October 5 : Pushing Pixels</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-231</link>
		<dc:creator>Swing links of the week: October 5 : Pushing Pixels</dc:creator>
		<pubDate>Mon, 06 Oct 2008 16:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-231</guid>
		<description>[...] Orr attacks the problem of JTable-in-a-JViewport and not filling the entire viewport. His solution employs a UI delegate that installs a custom layout manager on the enclosing [...]</description>
		<content:encoded><![CDATA[<p>[...] Orr attacks the problem of JTable-in-a-JViewport and not filling the entire viewport. His solution employs a UI delegate that installs a custom layout manager on the enclosing [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-229</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Mon, 06 Oct 2008 15:05:56 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-229</guid>
		<description>Hi bitguru,

The technique you suggest works for the simple case, where you only want to change the background color. This wouldn&#039;t work, though, if you wanted to draw row striping. I suppose you could install a custom JViewport on the JScrollpane, but it would have to have access to the JTable in order to draw the row striping.

Also note that if the JTable doesn&#039;t fill the view, you can only right click directly over the table to bring up a context menu and only drop items (for a D&amp;D operation) directly over the table.

-Ken</description>
		<content:encoded><![CDATA[<p>Hi bitguru,</p>
<p>The technique you suggest works for the simple case, where you only want to change the background color. This wouldn&#8217;t work, though, if you wanted to draw row striping. I suppose you could install a custom JViewport on the JScrollpane, but it would have to have access to the JTable in order to draw the row striping.</p>
<p>Also note that if the JTable doesn&#8217;t fill the view, you can only right click directly over the table to bring up a context menu and only drop items (for a D&amp;D operation) directly over the table.</p>
<p>-Ken</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bitguru</title>
		<link>http://explodingpixels.wordpress.com/2008/10/05/making-a-jtable-fill-the-view-without-extension/#comment-228</link>
		<dc:creator>bitguru</dc:creator>
		<pubDate>Mon, 06 Oct 2008 14:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://explodingpixels.wordpress.com/?p=284#comment-228</guid>
		<description>I had advocated simply calling yourScrollpane.getViewport().setBackground(matchingColor).

It doesn&#039;t stretch the table to be any larger, but it makes it harder to tell.</description>
		<content:encoded><![CDATA[<p>I had advocated simply calling yourScrollpane.getViewport().setBackground(matchingColor).</p>
<p>It doesn&#8217;t stretch the table to be any larger, but it makes it harder to tell.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
