如何更改 JFileChooser 标签"查看:"到"保存在:" (不是标题)?在这里,您可以看到我想要改变的内容:
答案 0 :(得分:4)
我找到了解决方案,也许对某人来说也是有用的:
JFileChooser chooser = new JFileChooser("Open");
//Set the text and language of all the components in JFileChooser
UIManager.put("FileChooser.openDialogTitleText", "Open");
UIManager.put("FileChooser.lookInLabelText", "LookIn");
UIManager.put("FileChooser.openButtonText", "Open");
UIManager.put("FileChooser.cancelButtonText", "Cancel");
UIManager.put("FileChooser.fileNameLabelText", "FileName");
UIManager.put("FileChooser.filesOfTypeLabelText", "TypeFiles");
UIManager.put("FileChooser.openButtonToolTipText", "OpenSelectedFile");
UIManager.put("FileChooser.cancelButtonToolTipText","Cancel");
UIManager.put("FileChooser.fileNameHeaderText","FileName");
UIManager.put("FileChooser.upFolderToolTipText", "UpOneLevel");
UIManager.put("FileChooser.homeFolderToolTipText","Desktop");
UIManager.put("FileChooser.newFolderToolTipText","CreateNewFolder");
UIManager.put("FileChooser.listViewButtonToolTipText","List");
UIManager.put("FileChooser.newFolderButtonText","CreateNewFolder");
UIManager.put("FileChooser.renameFileButtonText", "RenameFile");
UIManager.put("FileChooser.deleteFileButtonText", "DeleteFile");
UIManager.put("FileChooser.filterLabelText", "TypeFiles");
UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
UIManager.put("FileChooser.fileSizeHeaderText","Size");
UIManager.put("FileChooser.fileDateHeaderText", "DateModified");
//Set icons for the JFileChooser
UIManager.put("FileView.directoryIcon", new ImageIcon(FileSystem.class.getResource("folder.png")));
UIManager.put("FileChooser.homeFolderIcon", new ImageIcon(FileSystem.class.getResource("user-home.png")));
UIManager.put("FileView.computerIcon", new ImageIcon(FileSystem.class.getResource("computer.png")));
UIManager.put("FIleView.floppyDriveIcon", new ImageIcon(FileSystem.class.getResource("media-floppy.png")));
UIManager.put("FileView.hardDriveIcon", new ImageIcon(FileSystem.class.getResource("drive-harddisk.png")));
UIManager.put("FileView.fileIcon", new ImageIcon(FileSystem.class.getResource("file.png")));
UIManager.put("FileChooser.upFolderIcon", new ImageIcon(FileSystem.class.getResource("go.png")));
UIManager.put("FileChooser.newFolderIcon", new ImageIcon(FileSystem.class.getResource("folder-new.png")));
UIManager.put("FileView.fileIcon", new ImageIcon(FileSystem.class.getResource("file.png")));
UIManager.put("FileChooser.listViewIcon", new ImageIcon(FileSystem.class.getResource("listIcon.png")));
UIManager.put("FileChooser.detailsViewIcon", new ImageIcon(FileSystem.class.getResource("details.png")));
//Update UI
SwingUtilities.updateComponentTreeUI(chooser);
答案 1 :(得分:1)
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(0); // gives 'Look In'
chooser.setDialogType(1); // gives 'Save In'
答案 2 :(得分:1)