gpt4 book ai didi

java - JFileChooser 更改菜单按钮中的文本

转载 作者:行者123 更新时间:2023-12-02 09:35:39 28 4
gpt4 key购买 nike

我想更改“查看菜单”菜单下的“列表”按钮文本,但我找不到方法。这是文件选择器窗口的图片。

JFileChooser dialog window

我尝试了这些,但没有成功:

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");

preview

您可以在 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);
}

关于java - JFileChooser 更改菜单按钮中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57545390/

28 4 0