有一种方法可以更改 ApproveButtonText 的值
但我不知道如何更改“取消”按钮的值.. http://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html
我不想使用 JFileChooser#setLocale(Locale) 因为我需要在此按钮上自定义文本。
这里是如何设置“批准”选项,但没有“取消”选项。
JFileChooser Filechoose = new JFileChooser();
Filechoose.setApproveButtonText("Other text");
只是为了进一步澄清我的问题。我只想更改 JFileChoose 的一次出现。所以
UIManager.put("FileChooser.cancelButtonText", "NewValue");
SwingUtilities.updateComponentTreeUI(Filechoose);
可以工作,但我必须重命名JFileChooser Filechoose1 = new JFileChooser();
FileChoose1、FileCoose2 等。这就是解决方法。但是没有任何方法,比如 setApproveButtonText 吗?
最佳答案
如果您查看this,您可以找到更多信息讨论。
基本上,据我所知,这就是解决该问题的方法:
UIManager.put("FileChooser.cancelButtonText", "Cancel");
SwingUtilities.updateComponentTreeUI(Filechoose);
关于java - 更改 JFileChooser 的文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32054155/