<?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:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"
>

<channel>
	<title>acidum.de &#187; Swing</title>
	<atom:link href="http://www.acidum.de/tag/swing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.acidum.de</link>
	<description></description>
	<lastBuildDate>Sun, 08 Nov 2009 20:12:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Groovy Swing Builder + JTabbedPane</title>
		<link>http://www.acidum.de/2008/12/13/groovy-swing-builder-jtabbedpane/</link>
		<comments>http://www.acidum.de/2008/12/13/groovy-swing-builder-jtabbedpane/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 13:48:11 +0000</pubDate>
		<dc:creator>Christoph Hartmann</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Builder]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://www.acidum.de/?p=200</guid>
		<description><![CDATA[The groovy swing builder is one of Groovys best features. It becomes quite easy to build a gui with the builder. In some cases you may like to add a custom Java swing component to your swing builder. For such cases the swing builder is equipped with the widget() method. The following code uses the [...]]]></description>
			<content:encoded><![CDATA[<p>The groovy swing builder is one of Groovys best features. It becomes quite easy to build a gui with the builder. In some cases you may like to add a custom Java swing component to your swing builder. For such cases the swing builder is equipped with the widget() method. The following code uses the <a href="http://groovy.codehaus.org/SwingBuilder.tabbedPane">swing builder tabbed pane</a>  and add a custom component implemented in the getSearchPanel() method as tab.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.acidum.candystreams.gui</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">groovy.swing.SwingBuilder</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.SwingUtilities</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JFrame</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.BorderLayout</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JLabel</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JLabel</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JPanel</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CandystreamsClient <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Runnable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	CandystreamsClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// set system property to use mac os menu bar</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;apple.laf.useScreenMenuBar&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// set the application name for mac os</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;com.apple.mrj.application.apple.menu.about.name&quot;</span>, <span style="color: #0000ff;">&quot;CandyStreams&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		def swing <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SwingBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		def frame <span style="color: #339933;">=</span> swing.<span style="color: #006633;">frame</span><span style="color: #009900;">&#40;</span>title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;CandyStreams&quot;</span>,
			defaultCloseOperation<span style="color: #339933;">:</span> <span style="color: #003399;">JFrame</span>.<span style="color: #006633;">DISPOSE_ON_CLOSE</span>,
		    size<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">800</span>, <span style="color: #cc66cc;">600</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// add a simple menu bar</span>
			menuBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			    menu<span style="color: #009900;">&#40;</span>text<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;File&quot;</span>, mnemonic<span style="color: #339933;">:</span> <span style="color: #0000ff;">'F'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			      menuItem<span style="color: #009900;">&#40;</span>text<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Exit&quot;</span>, mnemonic<span style="color: #339933;">:</span> <span style="color: #0000ff;">'X'</span>, actionPerformed<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">exit</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: #009900;">&#41;</span>
			    <span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #666666; font-style: italic;">// add a tabbed pane</span>
			tabbedPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				panel<span style="color: #009900;">&#40;</span>title<span style="color: #339933;">:</span><span style="color: #0000ff;">'Panel 1'</span>, tabBackground<span style="color: #339933;">:</span>java.<span style="color: #006633;">awt</span>.<span style="color: #003399;">Color</span>.<span style="color: #006633;">GREEN</span>,tabToolTip<span style="color: #339933;">:</span><span style="color: #0000ff;">'Panel1'</span><span style="color: #009900;">&#41;</span>
                                <span style="color: #666666; font-style: italic;">// add custom swing component</span>
				widget<span style="color: #009900;">&#40;</span>title<span style="color: #339933;">:</span><span style="color: #0000ff;">'Search'</span>, getSearchPanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		frame.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> getSearchPanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">JPanel</span> panel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">JLabel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Search Panel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">return</span> panel
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">SwingUtilities</span>.<span style="color: #006633;">invokeLater</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> CandystreamsClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.acidum.de/2008/12/13/groovy-swing-builder-jtabbedpane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.346 seconds -->
