<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>jgoodies &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/jgoodies/</link>
	<description>Feed of posts on WordPress.com tagged "jgoodies"</description>
	<pubDate>Mon, 30 Nov 2009 11:15:07 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[JGoodies簡單介紹]]></title>
<link>http://undeadj.wordpress.com/?p=4</link>
<pubDate>Fri, 31 Jul 2009 15:45:27 +0000</pubDate>
<dc:creator>undeadj</dc:creator>
<guid>http://undeadj.wordpress.com/?p=4</guid>
<description><![CDATA[JGoodies是一個強而有力的第三方類別庫（third libary） 包含了JGoodies Forms、JGoodies Look、JGoodies Animation 首先JGoodies F]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://www.jgoodies.com"><img class="size-full wp-image-3 alignleft" title="looks" src="http://undeadj.wordpress.com/files/2009/07/looks.jpg" alt="looks" width="100" height="67" /></a><br />
JGoodies是一個強而有力的第三方類別庫（third libary）</p>
<p>包含了JGoodies Forms、JGoodies Look、JGoodies Animation</p>
<p>首先JGoodies Forms，它是一個強而有力的佈局管理員，Table型態的佈局、設定群組可以有相同寬度（高度）&#8230;等等，都可以使您的程式外觀看起來更加的前後一致。</p>
<p>再來說說JGoodies Look，它的L&#38;F（PlastXP）一直以來都是我很喜歡的一種，只是這個L&#38;F使用的是Tahoma來當作字型，所以顯示中文會出問題。除此之外，像是字型基準線的對齊、縮小button邊緣、embbedded tabs的JTabbedPane&#8230;等等，都不錯。</p>
<p>而JGoodies Animation，可以讓您完成類似電影開頭動畫般的動畫。您可以將這類的Animation放在程式啟動時，或其它任何地方（ex. About），來使您的程式更加的平易近人。</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Controlling UI Components using JGoodies Binding]]></title>
<link>http://kahdev.wordpress.com/2009/07/07/controlling-ui-components-using-jgoodies-binding/</link>
<pubDate>Tue, 07 Jul 2009 12:31:39 +0000</pubDate>
<dc:creator>kahgoh</dc:creator>
<guid>http://kahdev.wordpress.com/2009/07/07/controlling-ui-components-using-jgoodies-binding/</guid>
<description><![CDATA[In Binding with JGoodies Binding, the binding library from JGoodies was introduced with a relatively]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In <a href="http://kahdev.wordpress.com/2009/04/29/binding-with-jgoodies-binding/">Binding with JGoodies Binding</a>, the binding library from <a href="http://www.jgoodies.com">JGoodies</a> was introduced with a relatively simple example. The binding framework can also be used to automatically enable or disable user interface components depending on some condition.</p>
<p>A model is used to notify when the component should be enabled or disabled. This is a relatively simple model. It only needs to notify the library when the component should be enabled or disabled. I&#8217;ve called the model <i>Allowance</i>, as it is designed to notify when a feature or function is <b>allowed</b> to be used or performed rather than when something should be enabled or disabled. The code for the model is presented here:</p>
<p style="padding-left:30px;"><font face="monospace" color="#000000"><font color="#804040">&#160;1 </font><font color="#2e8b57"><b>public</b></font>&#160;<font color="#2e8b57"><b>class</b></font>&#160;Allowance <font color="#2e8b57"><b>extends</b></font>&#160;Model {<br />
<font color="#804040">&#160;2 </font><br />
<font color="#804040">&#160;3 </font>&#160;&#160;<font color="#2e8b57"><b>private</b></font>&#160;<font color="#2e8b57"><b>static</b></font>&#160;<font color="#2e8b57"><b>final</b></font>&#160;<font color="#2e8b57"><b>long</b></font>&#160;<br />
<font color="#804040">&#160;4 </font>&#160;&#160;&#160;&#160;serialVersionUID = <font color="#ff00ff">1L</font>;<br />
<font color="#804040">&#160;5 </font>&#160;&#160;<br />
<font color="#804040">&#160;6 </font>&#160;&#160;<font color="#2e8b57"><b>public</b></font>&#160;<font color="#2e8b57"><b>static</b></font>&#160;<font color="#2e8b57"><b>final</b></font>&#160;String<br />
<font color="#804040">&#160;7 </font>&#160;&#160;&#160;&#160;PROPERTY_ALLOWANCE = <font color="#ff00ff">&#34;allowed&#34;</font>;<br />
<font color="#804040">&#160;8 </font><br />
<font color="#804040">&#160;9 </font>&#160;&#160;<font color="#2e8b57"><b>private</b></font>&#160;<font color="#2e8b57"><b>boolean</b></font>&#160;allow = <font color="#ff00ff">false</font>;<br />
<font color="#804040">10 </font>&#160;&#160;<br />
<font color="#804040">11 </font>&#160;&#160;<font color="#2e8b57"><b>public</b></font>&#160;<font color="#2e8b57"><b>void</b></font>&#160;setAllowed(<font color="#2e8b57"><b>boolean</b></font>&#160;nowAllowed)&#160;<br />
<font color="#804040">12 </font>&#160;&#160;{<br />
<font color="#804040">13 </font>&#160;&#160;&#160;&#160;<font color="#2e8b57"><b>boolean</b></font>&#160;oldAllowed = allow;<br />
<font color="#804040">14 </font>&#160;&#160;&#160;&#160;allow = nowAllowed;<br />
<font color="#804040">15 </font>&#160;&#160;&#160;&#160;firePropertyChange(PROPERTY_ALLOWANCE,<br />
<font color="#804040">16 </font>&#160;&#160;&#160;&#160;&#160;&#160;oldAllowed, allow);<br />
<font color="#804040">17 </font>&#160;&#160;}<br />
<font color="#804040">18 </font><br />
<font color="#804040">19 </font>&#160;&#160;<font color="#2e8b57"><b>public</b></font>&#160;<font color="#2e8b57"><b>boolean</b></font>&#160;isAllowed()<br />
<font color="#804040">20 </font>&#160;&#160;{<br />
<font color="#804040">21 </font>&#160;&#160;&#160;&#160;<font color="#804040"><b>return</b></font>&#160;allow;<br />
<font color="#804040">22 </font>&#160;&#160;}<br />
<font color="#804040">23 </font>}<br />
</font></p>
<p>Next, the <b>Allowance</b> model needs to be bound to the UI component. In the previously mentioned tutorial, an editor for a book&apos;s subject and title was created and bound to a model for a book. Let&apos;s say that the title field will now be enabled only when a subject is selected and disabled at all other times. Models allows listeners to be attached to receive notification of changes to specific properties. Interested listeners must implement the <b>PropertyChangeListener</b> interface. Here is the corresponding block of code to implement this behaviour:</p>
<p style="padding-left:30px;"><font face="monospace" color="#000000"><font color="#2e8b57"><b>final</b></font>&#160;Allowance allowed = <font color="#804040"><b>new</b></font>&#160;Allowance();<br />
PropertyChangeListener allowanceUpdate =<br />
&#160;&#160;<font color="#804040"><b>new</b></font>&#160;PropertyChangeListener()&#160;{</p>
<p>&#160;&#160;&#160;&#160;<font color="#a020f0">@Override</font><br />
&#160;&#160;&#160;&#160;<font color="#2e8b57"><b>public</b></font>&#160;<font color="#2e8b57"><b>void</b></font>&#160;propertyChange(PropertyChangeEvent evt)&#160;{<br />
&#160;&#160;&#160;&#160;&#160;&#160;<font color="#804040"><b>if</b></font>&#160;(!evt.getNewValue().equals(<font color="#ff00ff">&#34;none&#34;</font>))&#160;{<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;allowed.setAllowed(<font color="#ff00ff">true</font>);<br />
&#160;&#160;&#160;&#160;&#160;&#160;} <font color="#804040"><b>else</b></font>&#160;{<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;allowed.setAllowed(<font color="#ff00ff">false</font>);<br />
&#160;&#160;&#160;&#160;&#160;&#160;}<br />
&#160;&#160;&#160;&#160;}<br />
&#160;&#160;};<br />
</font></p>
<p>The listener simply receives an event that contains information on the source of the event (i.e. the object with the changed property) and the old and new values of the property.</p>
<p>To be of any use, the listener has to be attached to our model. There are a few options on how this could be done. The listener can be directly attached to our model or indirectly via the same presentation model used in creating the editor. Generally, I recommend going through presentation model, as that would allow you to change the instance being edited much more easily. The listener requires knowledge of changes to the subject only. The binding library allows listeners to be notified of only changes to the subject. To attach the listener:</p>
<p style="padding-left:30px;"><font face="monospace" color="#000000">presentation.getModel(Book.PROPERTY_TOPIC).<br />
&#160;&#160;addPropertyChangeListener(allowanceUpdate);<br />
</font></p>
<p>The call to <b>getModel()</b> will retrieve the value model for the subject property of the book model. When you want to change the instance of the model that is being edited, you can use the presentation model&apos;s <b>setBean()</b> to load the new instance. If the listener had been attached to the our object, we would have to move the listener to the new instance ourselves. This is why I prefer going through the presentation model.</p>
<p>Finally, the allowance model needs to somehow be connected to the UI component. The line to do this:</p>
<p style="padding-left:30px;"><font face="monospace" color="#000000">PropertyConnector connection =<br />
&#160;&#160;PropertyConnector.connect(nameField, &#34;enable&#34;,<br />
&#160;&#160;&#160;&#160;allowed, Allowance.PROPERTY_ALLOWANCE);<br />
allowed.setAllowed(false);<br />
connection.updateProperty1();<br />
</font></p>
<p>The <b>PropertyConnector</b> will automatically listen for changes to the <b>Allowance</b> and update the &#34;enable&#34; property of the component. Note that the &#34;enable&#34; property could have also been substituted for &#34;visible&#34; to have it change its visibility or &quoy;editable&#34; to change whether it is editable or not. Using any of these properties will effectively control whether the user is able to edit the contents of the text field. There are also a few other properties that can be controlled in this way, such as &#34;focusable&#34; and &#34;opaque&#34;. Files from this tutorial are downloadable from <a href="http://www.box.net/shared/5akh3b7r4v">here</a></p>
<p>While in the example an <b>Allowance</b> model was created for the purpose of modelling when a component can be used or not, it should be noted that the binding library provides <b>ComponentValueModel</b> to control three of the properties &#8211; visible, editable and enabled. The model provides three separate methods for controlling the properties separately &#8211; <b>setEditable</b>, <b>setEnabled</b> and <b>setVisible</b>. Instead of using <b>PropertyConnector</b> to bind the model to the UI component, you should using <b>Binding.addComponentPropertyHandler</b> instead.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Binding with JGoodies Binding]]></title>
<link>http://kahdev.wordpress.com/2009/04/29/binding-with-jgoodies-binding/</link>
<pubDate>Wed, 29 Apr 2009 13:10:06 +0000</pubDate>
<dc:creator>kahgoh</dc:creator>
<guid>http://kahdev.wordpress.com/2009/04/29/binding-with-jgoodies-binding/</guid>
<description><![CDATA[The binding framework allows you to write classes that represents model completely independent of th]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><P>The binding framework allows you to write classes that represents model completely independent of the user interface. The classes are bound to the user interface and are updated as the user interface enters information. The frame is based on the <A HREF="http://martinfowler.com/eaaDev/PresentationModel.html">presentation pattern</A>, described by Martin Fowler. </P></p>
<p><P STYLE="margin-bottom: 0cm">The framework already provides a <b>Model</b> class. Classes containing attributes that are editable on the user interface would be a subclass of this. It adds functionality to notify of events. By default, the frame assumes that the used naming conventions for the properties, accessors and mutator methods follow the same pattern as suggested in the <A HREF="http://java.sun.com/javase/technologies/desktop/javabeans/docs/spec.html">Java beans specification</A>. For the models that I create, I provide the property as a public constant within the model. The mutator code also need to call the model&#8217;s firePropertyChange method to notify listeners of a change to the property. For example, a model for a book could be the following:</P></p>
<p><font face="monospace"><span style="color:rgb(0,0,0);">&#8230;</span><br />
<span style="font-weight:bold;color:rgb(127,0,85);">public</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">class</span>&#160;<span style="color:rgb(0,0,0);">Book</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">extends</span>&#160;<span style="color:rgb(0,0,0);">Model</span>&#160;<br />
<span style="color:rgb(0,0,0);">{</span><br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></p>
<p>&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">/**</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="color:rgb(63,95,191);">References</span>&#160;<span style="color:rgb(63,95,191);">to</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">properties</span>&#160;<span style="color:rgb(63,95,191);">for</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">model.</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*/</span><br />
&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">public</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">static</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">final</span>&#160;<span style="color:rgb(0,0,0);">String</span>&#160;<span style="color:rgb(0,0,0);">PROPERTY_TITLE</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(42,0,255);">&#34;title&#34;</span><span style="color:rgb(0,0,0);">;</span><br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></p>
<p>&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">/**</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="color:rgb(63,95,191);">Keeps</span>&#160;<span style="color:rgb(63,95,191);">track</span>&#160;<span style="color:rgb(63,95,191);">of</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">title</span>&#160;<span style="color:rgb(63,95,191);">of</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">book.</span>&#160;<br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*/</span><br />
&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">private</span>&#160;<span style="color:rgb(0,0,0);">String</span>&#160;<span style="color:rgb(0,0,0);">title</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(42,0,255);">&#34;&#160;&#34;</span><span style="color:rgb(0,0,0);">;</span></p>
<p>&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></p>
<p>&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">/**</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="color:rgb(63,95,191);">Changes</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">title</span>&#160;<span style="color:rgb(63,95,191);">of</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">book.</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="font-weight:bold;color:rgb(127,159,191);">@param</span>&#160;<span style="color:rgb(63,95,191);">newTitle</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">The</span>&#160;<span style="color:rgb(63,95,191);">new</span>&#160;<span style="color:rgb(63,95,191);">title</span>&#160;<span style="color:rgb(63,95,191);">for</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">book.</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*/</span><br />
&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">public</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">void</span>&#160;<span style="color:rgb(0,0,0);">setTitle(String</span>&#160;<span style="color:rgb(0,0,0);">newTitle)</span>&#160;<br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">{</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">String</span>&#160;<span style="color:rgb(0,0,0);">oldTitle</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(0,0,0);">title;</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">title</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(0,0,0);">newTitle;</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">firePropertyChange(PROPERTY_TITLE,</span>&#160;<span style="color:rgb(0,0,0);">oldTitle,</span>&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">newTitle);</span><br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">}</span><br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">/**</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="font-weight:bold;color:rgb(127,159,191);">@return</span>&#160;<span style="color:rgb(63,95,191);">The</span>&#160;<span style="color:rgb(63,95,191);">title</span>&#160;<span style="color:rgb(63,95,191);">of</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">book.</span><br />
&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*/</span><br />
&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">public</span>&#160;<span style="color:rgb(0,0,0);">String</span>&#160;<span style="color:rgb(0,0,0);">getTitle()</span>&#160;<br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">{</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">return</span>&#160;<span style="color:rgb(0,0,0);">title;</span><br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">}</span><br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span><br />
<span style="color:rgb(0,0,0);">}</span></font></p>
<p>For creating the user interface components that will be editing the model, the <b>PresentationModel</b> is created for the object. The <b>PresentationModel</b> provides a representation of the user interface. The framework also supplies a <b>BasicComponentFactory</b> that you can use to create the components. The factory will also bind the component to the appropriate attribute. The methods that create text fields require a value model as one of its paramters. The value model is what is actually updated when the user makes changes in the component and it should be retrieved from the <b>PresentationModel</b> using its <b>getModel</b> method. For example, to create a text field for entering the title of a book:</p>
<p><span style="font-family:courier new;font-size:10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">final</span>&#160;<span style="color:rgb(0,0,0);">Book</span>&#160;<span style="color:rgb(0,0,0);">subject</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">new</span>&#160;<span style="color:rgb(0,0,0);">Book();</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">final</span>&#160;<span style="color:rgb(0,0,0);">PresentationModel&#60;Book&#62;</span>&#160;<span style="color:rgb(0,0,0);">presentation</span>&#160;<span style="color:rgb(0,0,0);">=</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">new</span>&#160;<span style="color:rgb(0,0,0);">PresentationModel&#60;Book&#62;(subject);</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">JTextField</span>&#160;<span style="color:rgb(0,0,0);">nameField</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(0,0,0);">BasicComponentFactory.</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">createTextField(presentation.getModel(</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">Book.PROPERTY_TITLE),</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">false</span><span style="color:rgb(0,0,0);">);</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></span></p>
<p>The third parameter, which is set to <b>false</b> will cause the bounded instance to be updated as the user makes changes in the text field. Setting it to <b>true</b> will result in the changes being made only when the field loses focus instead. </p>
<p>In the case of list selection fields, such as a <b>JList</b> and <b>JComboBox</b>, the required model is a <b>SelectionInList</b>. <b>SelectionInList</b> provides the functionality for tracking changes in the selection. Setting up a <b>SelectionInList</b> might require a few different calls. </p>
<p><font face="monospace">&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span><br />
&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">public</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">static</span>&#160;<span style="font-weight:bold;color:rgb(127,0,85);">final</span>&#160;<span style="color:rgb(0,0,0);">String</span>&#160;<span style="color:rgb(0,0,0);">TOPICS[]</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">{</span><span style="color:rgb(42,0,255);">&#34;science&#34;</span><span style="color:rgb(0,0,0);">,</span>&#160;<span style="color:rgb(42,0,255);">&#34;history&#34;</span><span style="color:rgb(0,0,0);">,</span>&#160;<span style="color:rgb(42,0,255);">&#34;arts&#34;</span><span style="color:rgb(0,0,0);">};</span><br />
&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">SelectionInList&#60;String&#62;</span>&#160;<span style="color:rgb(0,0,0);">topicSelect</span>&#160;<span style="color:rgb(0,0,0);">=</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="font-weight:bold;color:rgb(127,0,85);">new</span>&#160;<span style="color:rgb(0,0,0);">SelectionInList&#60;String&#62;(TOPICS);</span></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">/**</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="color:rgb(63,95,191);">Set</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">presentation</span>&#160;<span style="color:rgb(63,95,191);">model</span>&#160;<span style="color:rgb(63,95,191);">as</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">model</span>&#160;<span style="color:rgb(63,95,191);">that</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*</span>&#160;<span style="color:rgb(63,95,191);">holds</span>&#160;<span style="color:rgb(63,95,191);">the</span>&#160;<span style="color:rgb(63,95,191);">selected</span>&#160;<span style="color:rgb(63,95,191);">value.</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(63,95,191);">*/</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">topicSelect.setSelectionHolder(</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">presentation.getModel(</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">Book.PROPERTY_TOPIC));</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">JComboBox</span>&#160;<span style="color:rgb(0,0,0);">topicBox</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(0,0,0);">BasicComponentFactory.</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">createComboBox(topicSelect);</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></font></p>
<p>The <b>SelectionInList</b> class has a few different constructors that allow you to specify the set of possible options as a list or an array. The call to <b>setSelectionHolder</b> will make updates to the presention model as the selection of the value is changed.</p>
<p>The <b>BasicComponentFactory</b> can also create <b>JLabel</b> that displays the current value of an attribute in the model. The label gets updated as the value of the attribute changes.</p>
<p><span style="font-family:courier new;font-size:10pt;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">JLabel</span>&#160;<span style="color:rgb(0,0,0);">titleLabel</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(0,0,0);">BasicComponentFactory.</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">createLabel(presentation.getModel(</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">Book.PROPERTY_TITLE));</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">JLabel</span>&#160;<span style="color:rgb(0,0,0);">topicLabel</span>&#160;<span style="color:rgb(0,0,0);">=</span>&#160;<span style="color:rgb(0,0,0);">BasicComponentFactory.</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">createLabel(presentation.getModel(</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">Book.PROPERTY_TOPIC));</span><br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:rgb(0,0,0);">&#8230;</span></span></p>
<p>Since the title property has been bound to the title text field, the <b>titleLabel</b> will be automatically updated when the user makes changes in the field. Similarly, topic property has been bound such that when the user changes its selection, it the <b>topicLabel</b> will be updated. If you wish to try out the examples from here, you can get the source code <a href="http://www.box.net/shared/8z6rushe9b">here</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Building up the framework]]></title>
<link>http://danielrohe.wordpress.com/2008/06/18/building-up-the-framework/</link>
<pubDate>Wed, 18 Jun 2008 02:21:28 +0000</pubDate>
<dc:creator>danielrohe</dc:creator>
<guid>http://danielrohe.wordpress.com/2008/06/18/building-up-the-framework/</guid>
<description><![CDATA[After the application displays an application frame and shuts down when the user closes the frame it]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>After the application displays an application frame and shuts down when the user closes the frame it is time to define the frameworks which are part of the application platform.</p>
<p>The application platform provides the JGoodies Forms, Binding and Validation libraries as part of the framework. Beside the core JGoodies libraries the application platform also provides extension like the SingleListSelectionUpdater described in an earlier post. It is an replacement of JGoodies Binding&#8217;s SingleListSelectionAdapter and can handle sorting and filtering in a table.</p>
<p>Also the application platform defines a framework for a form where the user views and edits domain objects. Common forms would be an editor form with input fields for attributes of the domain object or forms with lists which display a set of domain objects. From a design point these forms work on presentation models or list models. Forms are suposed to have no control logic except the propagation of text from input fields to domain objects. The control logic will be provided by another framework around different forms.</p>
<p>The control logic is provided by a page framework which provides the control logic executing operations on user requests through clicking a button, pressing an accelerator or hitting a keyboard shortcut.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Validation-Feedback mit JGoodies Validation am JSpinner]]></title>
<link>http://danielrohe.wordpress.com/2007/11/04/validation-feedback-mit-jgoodies-validation-am-jspinner/</link>
<pubDate>Sat, 03 Nov 2007 23:37:32 +0000</pubDate>
<dc:creator>danielrohe</dc:creator>
<guid>http://danielrohe.wordpress.com/2007/11/04/validation-feedback-mit-jgoodies-validation-am-jspinner/</guid>
<description><![CDATA[Eine Desktopanwendung ohne Feedback bei Validierungsfehlern ist einfach nicht mehr zeitgemäß. Ich ve]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Eine Desktopanwendung ohne Feedback bei Validierungsfehlern ist einfach nicht mehr zeitgemäß. Ich verwende für das visuelle Feedback von Validierungsfehlern JGoodies Validation 2.0.x. Diese Bibliothek arbeitet sehr gut für JTextField und deren Subklassen.</p>
<p>Für das Feedback in einem JSpinner kann man aber einen Workaround verwenden. JSpinner ist eine Swing-Komponente, die neben einem Eingabefeld zwei Buttons zum Erhöhen bzw. Verringern eines Wertes im SpinnerModel hat. Das Eingabefeld selbst ist dabei wieder ein JTextField oder eine Subklasse davon. Deswegen kann assoziiert folgender Code das Eingabefeld mit den MessageKeys:</p>
<pre>ValidationComponentUtils.setMessageKey(((JSpinner.DefaultEditor)
  spinner.getEditor()).getTextField(), "ExampleBean.SampleProperty");</pre>
<p>Oder wenn man ein eigenes Eingabefeld als Editor im JSpinner verwendet:</p>
<pre>ValidationComponentUtils.setMessageKey(
  spinner.getEditor(), "ExampleBean.SampleProperty");</pre>
<p>Das folgende Bild zeigt zwei JSpinner, welche beide Pflichtfelder sind und bei einem ein Validierungsfehler aufgetreten ist.</p>
<p><a href="http://danielrohe.wordpress.com/files/2008/05/jspinner-validationfeedback.png"><img class="alignnone size-medium wp-image-7" src="http://danielrohe.wordpress.com/files/2008/05/jspinner-validationfeedback.png?w=237" alt="JSpinner Validation Feedback" width="237" height="300" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JGoodies SingleListSelectionAdapter]]></title>
<link>http://danielrohe.wordpress.com/2007/09/22/jgoodies-singlelistselectionadapter/</link>
<pubDate>Sat, 22 Sep 2007 01:23:04 +0000</pubDate>
<dc:creator>danielrohe</dc:creator>
<guid>http://danielrohe.wordpress.com/2007/09/22/jgoodies-singlelistselectionadapter/</guid>
<description><![CDATA[Nachdem ich eine kleine Anwendung geschrieben zum Zeitmanagement geschrieben habe, wollte ich mal ei]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Nachdem ich eine kleine Anwendung geschrieben zum Zeitmanagement geschrieben habe, wollte ich mal ein wenig damit spielen. Also ein paar Einträge eingefügt und die Tabelle sortiert (ich verwende JXTable, das gleiche Verhalten ist aber im JDK6 vorhanden) und dann versucht den selektierten Eintrag zu bearbeiten. Dabei ist es passiert! JGoodies Binding SingleListSelectionAdapter in Verbindung mit JXTable oder JDK6 JTable funktioniert nicht mit sortierten Tabellen. Der Grund: Das SelectionModel der Tabelle enthält die angezeigt Auswahl und nicht die unsortierten Indices. Lösung: Ich hab eine SelectionListener-Implementierung geschrieben. die Implementierung nutzt die Tabelle um die Auswahl umzuwandeln und die Auswahl korrekt an ein ValueModel weitergibt.</p>
<p><a href="http://danielrohe.wordpress.com/files/2008/05/singlelistselectionupdater.odt">singlelistselectionupdater</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Resizing mit JGoodies FormLayout]]></title>
<link>http://danielrohe.wordpress.com/2007/09/11/resizing-mit-jgoodies-formlayout/</link>
<pubDate>Tue, 11 Sep 2007 16:02:50 +0000</pubDate>
<dc:creator>danielrohe</dc:creator>
<guid>http://danielrohe.wordpress.com/2007/09/11/resizing-mit-jgoodies-formlayout/</guid>
<description><![CDATA[JGoodies FormLayout bietet die Möglichkeit beim layouten von Komponenten in Container mit pref oder ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>JGoodies FormLayout bietet die Möglichkeit beim layouten von Komponenten in Container mit <em>pref</em> oder <em>default</em> die Größen von Komponenten zu benutzen. Wenn diese Komponenten sich noch dynamisch der Größe des Containers anpassen sollen, aka mitwachsen sollen verwendet man den Parameter <em>grow</em>.</p>
<p>Problematisch wird es wenn der Inhalt von Textfeldern oder Combo-Boxen sehr groß ist. Verwendet man <em>pref</em> oder <em>default</em> dann wachsen die Komponenten aus dem Container und man kann den rechten Rand nicht mehr sehen. Deswegen muss man in diesem Fall anstelle der Komponentengrößen feste Größen verwenden und die Komponenten wachsen lassen. Z.B. <em>160dlu:grow</em> um eine Größe von 160 Dialogeinheiten als Minimum und die Komponente kann bei Bedarf den restlichen Platz verwenden anstelle von <em>default:grow</em>.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
