all I want to do is autowire the field backgroundGray in the NotesPanel class, but all I get is the exception below.
So, question is, how to autowire it correctly ? It r
I share with you an example. I hope you love it :)
public class Main {
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager
.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception ex) {
ex.printStackTrace();
}
new Ihm().setVisible(true);
}
});
}
}
My configuration bean:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@ComponentScan("com.myproject.configuration")
@PropertySource("classpath:/application.properties")
public class Config {
@Bean
public Configurator configurator() {
return new Configurator();
}
}
My java swing ihm that uses my configuration bean:
public class Ihm extends JFrame {
private MyConfiguration configuration;
public SmartRailServerConfigurationFileIhm() {
try {
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
configurator = context.getBean(MyConfiguration.class);
} catch (Exception ex) {
}
System.out.println(configuration);
...
...
}
}