Reputation: 2969
I am creating a swing application with using spring boot. and the frame that i try to use is registered as a component in the application context.
@Bean
public UploadForm createUploadForm(){
return new UploadForm();
}
this is how i started the application at first
public static void main(String[] args) throws Exception{
SpringApplicationBuilder springApplicationBuilder = new SpringApplicationBuilder(Application.class);
springApplicationBuilder.headless(false);
ConfigurableApplicationContext context = springApplicationBuilder.run(args);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
EventQueue.invokeLater(() -> {
UploadForm uploadForm = context.getBean(UploadForm.class);
uploadForm.setVisible(true);
});
}
but with this way file chooser appear in the same old way. but if we use new UploadForm instead of the registered bean in the context everything looks fine, jfilechooser appear in the windows look and feel format
UploadForm uploadForm = new UploadForm();
uploadForm.setVisible(true);
Upvotes: 0
Views: 76
Reputation: 1448
You need to set the look and feel before the bean is constructed. Try to move the line UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
before context creation.
Upvotes: 1