I'm using JTattoo to change my application LookAndFeel. I know how to set any of the available skins, but now I want the user to be able to choose anyone of them. A string with the LAF is being saved in a file, so everytime you run the program it's supposed to read this file and set the skin according to your choice.
I've made a JDialogBox appear before the GUI just to show if the file has been read properly, and it was.
This is working:
UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");
But this is not:
UIManager.setLookAndFeel(chooseSkin());
Any idea?
PS: The String in the file is correct, I've checked it like a million times, I've tried it with quotes, without them... I don't know what to do now
EDIT: Note that there is no method called chooseSkin(), it was just an easy refference, the real method is called readFile()
Skins.java
public static String readFile() {
String content = "";
File file = new File("skins.txt");
try {
FileReader reader = new FileReader(file);
char[] chars = new char[(int) file.length()];
reader.read(chars);
content = new String(chars);
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(content); // ---> returns: "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"
return content;
}
Main.java
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
System.out.println(Skins.readFile() =="com.jtattoo.plaf.aluminium.AluminiumLookAndFeel"); // ---> returns false
UIManager.setLookAndFeel(Skins.readFile());
MainGUI frame = new MainGUI();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}