
所有需要做的就是在创建JFileChooser对象时更改UIManager,然后将其设置回之前的状态,或者您可以仅捕获Exception,但这是一个不好的做法。
public void stuff(){ JFileChooser chooser = null; LookAndFeel previousLF = UIManager.getLookAndFeel(); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); chooser = new JFileChooser(); UIManager.setLookAndFeel(previousLF); } catch (IllegalAccessException | UnsupportedLookAndFeelException | InstantiationException | ClassNotFoundException e) {} //Add whatever other settings you want to the method chooser.showOpenDialog(frame);}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)