I am using a net beans form to create an applet. The applet relies on a JFileChooser. If I write the program as an application instead of an applet, the file chooser looks different. Why does the same code produce different looking file choosers when written as an applet or an application? Also, how can I change the look and feel of my file chooser from the applet to look like the file chooser from the application?
Application file chooser:
Applet file chooser:
When you invoke UIManager.setLookAndFeel(…)
in your application, existing components are not automatically updated as there is no global registry of all existing component. Hence, these components will look different than the components created afterwards. You may invoke updateUI()
on a component to update it to the current look and feel. There is also the utility method SwingUtilities.updateComponentTreeUI(…)
which will call updateUI()
on an entire component tree, recursively.
But generally, it’s better to set the desired look and feel as early as possible, preferably before creating any component, to avoid the necessity to update existing components.