I am using Spring framework for my java Swing application. I am initializing my MVC objects as spring bean in my application-context.xml in this way, with @Autowired for DI.
<bean id="model" class="com.Model"/>
<bean id="view" class="com.View"/>
<bean id="controller" class="com.Controller"/>
It runs successfully without any problem. However by reading at this question, I think I should put every Swing components inside SwingUtilities.invokerLater() for this reason.
Some Swing component methods are labelled "thread safe" in the API specification; these can be safely invoked from any thread. All other Swing component methods must be invoked from the event dispatch thread. Programs that ignore this rule may function correctly most of the time, but are subject to unpredictable errors that are difficult to reproduce.
So my question is, where/how to put my stuff to this Event Dispatch Thread? Currently my main method is just a one liner...
ApplicationContext context =
new ClassPathXmlApplicationContext("application-context.xml");
UPDATE: I wanna know if this is what I should do?
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ApplicationContext context =
new ClassPathXmlApplicationContext("application-context.xml");
}
context.xxxx
blahblahblah...
});