Java JFileChooser从菜单按钮更改文本
我想更改“查看菜单”菜单下的“列表”按钮文本,但找不到方法。这是文件选择器窗口的图片 我试过这些,但没有成功:Java JFileChooser从菜单按钮更改文本,java,swing,jfilechooser,uimanager,Java,Swing,Jfilechooser,Uimanager,我想更改“查看菜单”菜单下的“列表”按钮文本,但找不到方法。这是文件选择器窗口的图片 我试过这些,但没有成功: UIManager.put("FileChooser.listViewButtonText", "Test1"); UIManager.put("FileChooser.listViewButtonName", "Test2"); UIManager.put("FileChooser.listButtonText", "Test3"); UIManager.put("FileChoo
UIManager.put("FileChooser.listViewButtonText", "Test1");
UIManager.put("FileChooser.listViewButtonName", "Test2");
UIManager.put("FileChooser.listButtonText", "Test3");
UIManager.put("FileChooser.listViewButtonAccessibleName", "Test4");
chooser.updateUI();
有人遇到过这个吗?此外,如果可能的话,我想改变右击菜单文本以及
提前感谢。这些是必须更改的值:
UIManager.put("FileChooser.detailsViewActionLabelText", "mytext");
UIManager.put("FileChooser.listViewActionLabelText", "myothertext");
您可以在installDefaults
方法中的sun.swing.FilePane
类中查看安装的值:
protected void installDefaults() {
Locale l = getFileChooser().getLocale();
listViewBorder = UIManager.getBorder("FileChooser.listViewBorder");
listViewBackground = UIManager.getColor("FileChooser.listViewBackground");
listViewWindowsStyle = UIManager.getBoolean("FileChooser.listViewWindowsStyle");
readOnly = UIManager.getBoolean("FileChooser.readOnly");
// TODO: On windows, get the following localized strings from the OS
viewMenuLabelText = UIManager.getString("FileChooser.viewMenuLabelText", l);
refreshActionLabelText = UIManager.getString("FileChooser.refreshActionLabelText", l);
newFolderActionLabelText = UIManager.getString("FileChooser.newFolderActionLabelText", l);
viewTypeActionNames = new String[VIEWTYPE_COUNT];
viewTypeActionNames[VIEWTYPE_LIST] = UIManager.getString("FileChooser.listViewActionLabelText", l);
viewTypeActionNames[VIEWTYPE_DETAILS] = UIManager.getString("FileChooser.detailsViewActionLabelText", l);
kiloByteString = UIManager.getString("FileChooser.fileSizeKiloBytes", l);
megaByteString = UIManager.getString("FileChooser.fileSizeMegaBytes", l);
gigaByteString = UIManager.getString("FileChooser.fileSizeGigaBytes", l);
fullRowSelection = UIManager.getBoolean("FileView.fullRowSelection");
renameErrorTitleText = UIManager.getString("FileChooser.renameErrorTitleText", l);
renameErrorText = UIManager.getString("FileChooser.renameErrorText", l);
renameErrorFileExistsText = UIManager.getString("FileChooser.renameErrorFileExistsText", l);
}
非常感谢。这是正确的方法!你还知道当使用鼠标(右键单击)时如何更改菜单标签吗?虽然我只需要3行,但你给出了代码,使其根据本地语言自动进行更改。谢谢你,因为这是我要的!