This is the code that I use at the moment but it really spoils the whole beautifullness of the program. I would like this function to apply only to JFilechooser without changing of all other components like JButton etc.
I just find the native Java filechooser to be very ugly and inconvinient compared to native Windows style.
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
After I received an answer and looked into the link it helped me to solve my problem. I will post the code that I now use in order to help anyone that will ever need this.
Solution found:
import javax.swing.JFileChooser;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class window {
public static void main(String[] args) {
//Open file chooser
JFileChooser chooser = windowsJFileChooser(new JFileChooser());//Create file chooser
chooser.showSaveDialog(null);
}
/**
* This method returns JFileChooser with Windows look instead of native java
* @param chooser
*/
public static JFileChooser windowsJFileChooser(JFileChooser chooser){
LookAndFeel previousLF = UIManager.getLookAndFeel();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
chooser = new JFileChooser();
UIManager.setLookAndFeel(previousLF);
} catch (IllegalAccessException | UnsupportedLookAndFeelException | InstantiationException | ClassNotFoundException e) {}
return chooser;
}
}