title: How to configure a Swing JFrame as a Spring bean?
body: <p>I have a simple JFrame as the main window of my Java desktop application and I would like to configure it as a Spring bean. I would like to set properties, inject dependencies and launch it. Here's my frame class:</p>
  
  <pre><code>public class MainFrame extends JFrame {
      public MainFrame() {
          setTitle("Static Title");
          setVisible(true);
      }
  }
  </code></pre>
  
  <p>My Spring application context:</p>
  
  <pre><code>&lt;bean class="com.example.MainFrame"&gt;
      &lt;property name="title" value="Injected Title" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Then I fire it all up...</p>
  
  <pre><code>public static void main(String ... args) {
      new ClassPathXmlApplicationContext("applicationContext.xml");
  }
  </code></pre>
  
  <p>...which is followed by this <code>java.beans.IntrospectionException</code>:</p>
  
  <pre><code>type mismatch between indexed and non-indexed methods: location
  </code></pre>
  
  <p>The frame is actually displayed but there's that exception and the title remains "Static Title". So I have a few questions...</p>
  
  <p>I've seen this being <a href="http://www.ibm.com/developerworks/java/tutorials/j-springswing/section4.html" rel="nofollow">done by IBM in a 2005 tutorial</a> but with Spring 1.2, and I don't even know what JRE. So how do I approach this exception? Is it possible to configure a JFrame as a Spring bean or do I need to proxy it or something?</p>
  
  <p>I'm also wary of not launching the application from the event dispatching thread. So if there's a cleaner way of doing this I'd like to know about it. I can easily dispatch everything except that I don't know how to dispatch the construction itself.</p>
  
  <p>Finally feel free to criticise the overall concept. I haven't come across many examples of Spring managed Swing applications. I'm using Spring-3.1 with Java-1.6.</p>
  
  <p>Thanks.</p>