我正在制作一个程序选择工具,目前我喜欢整个界面与 Java LookAndFeel 很相似。唯一想要更改的是 JFileChooser 的 LookAndFeel 为 Windows。当我调用 filechooser 并告诉它更改 LookAndFeel 时,它没有任何反应。当我在程序启动时调用它,它使按钮的外观变得不好看。因此,谷歌上没有任何解决方案,我也无法找到解决办法。请帮帮我!让我知道哪些代码相关且有用。提前感谢!
编辑:
下面是一些关于 JFileChooser 的代码及其启动方式:
public class Start(){
public static JButton assignButton = new JButton(new AbstractAction(
"Assign") {
public void actionPerformed(ActionEvent e) {
AssignWindow.run();
}
});
}
public class AssignmentWindow(){
public static void run() {
Dialogs.assignmentInfo();
bgImage = aw.getImage("files/background.png");
//aw is the object of this class
aw.makeFrame(); //makes the jframe for all the buttons to sit.
aw.setGraphics(); //assigns a different graphics variable
aw.fileChooser();
}
public void fileChooser() {
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
// here is where i want to set the look and feel....
if (jfc.showDialog(null, "Select") == JFileChooser.APPROVE_OPTION) {
File file = jfc.getSelectedFile();
fileDir = file.getPath();
} else {
Dialogs.msg("You cancled selecting a file. Returning to file frame...");
AssignWindow.destroy();
}
}
}