本文整理汇总了Java中javax.swing.JFileChooser.setControlButtonsAreShown方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.setControlButtonsAreShown方法的具体用法?Java JFileChooser.setControlButtonsAreShown怎么用?Java JFileChooser.setControlButtonsAreShown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.setControlButtonsAreShown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareFileChooser
import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void prepareFileChooser(JFileChooser chooser) {
chooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY
: filesOnly ? JFileChooser.FILES_ONLY :
JFileChooser.FILES_AND_DIRECTORIES);
chooser.setFileHidingEnabled(fileHiding);
chooser.setControlButtonsAreShown(controlButtonsShown);
chooser.setAcceptAllFileFilterUsed(useAcceptAllFileFilter);
if (title != null) {
chooser.setDialogTitle(title);
}
if (approveText != null) {
chooser.setApproveButtonText(approveText);
}
if (badger != null) {
chooser.setFileView(new CustomFileView(new BadgeIconProvider(badger),
chooser.getFileSystemView()));
}
if (PREVENT_SYMLINK_TRAVERSAL) {
FileUtil.preventFileChooserSymlinkTraversal(chooser,
chooser.getCurrentDirectory());
}
if (filter != null) {
chooser.setFileFilter(filter);
}
if (aDescription != null) {
chooser.getAccessibleContext().setAccessibleDescription(aDescription);
}
if (!filters.isEmpty()) {
for (FileFilter f : filters) {
chooser.addChoosableFileFilter(f);
}
}
}
示例2: LoadDialog
import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
* Creates a dialog to choose a file to load.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param directory The directory to display when choosing the file.
* @param fileFilters The available file filters in the dialog.
*/
public LoadDialog(FreeColClient freeColClient, JFrame frame,
File directory, FileFilter[] fileFilters) {
super(freeColClient, frame);
final JFileChooser fileChooser = new JFileChooser(directory);
if (fileFilters.length > 0) {
for (FileFilter fileFilter : fileFilters) {
fileChooser.addChoosableFileFilter(fileFilter);
}
fileChooser.setFileFilter(fileFilters[0]);
fileChooser.setAcceptAllFileFilterUsed(false);
}
fileChooser.setControlButtonsAreShown(true);
fileChooser.setApproveButtonText(Messages.message("ok"));
//fileChooser.setCancelButtonText(Messages.message("cancel"));
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setFileHidingEnabled(false);
fileChooser.addActionListener((ActionEvent ae) -> {
final String cmd = ae.getActionCommand();
File value = (JFileChooser.APPROVE_SELECTION.equals(cmd))
? ((JFileChooser)ae.getSource()).getSelectedFile()
: cancelFile;
setValue(value);
});
List<ChoiceItem<File>> c = choices();
initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
示例3: initialize
import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setTitle("MD5");
frame.setResizable(false);
frame.setBounds(100, 100, 450, 580);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel label = new JLabel("Please select your files:");
label.setBounds(105, 32, 227, 16);
frame.getContentPane().add(label);
final JLabel error = new JLabel("");
error.setForeground(new Color(255,0,0));
error.setBounds(120, 52, 250, 16);
frame.getContentPane().add(error);
final JFileChooser filesChooser = new JFileChooser();
filesChooser.setControlButtonsAreShown(false);
filesChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
filesChooser.setMultiSelectionEnabled(true);
filesChooser.setBounds(41, 62, 362, 400);
frame.getContentPane().add(filesChooser);
JButton btnStartMD5 = new JButton("Start MD5");
btnStartMD5.setBounds(132, 490, 177, 29);
frame.getContentPane().add(btnStartMD5);
//listener to run the application launch when the button is pressed
btnStartMD5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// It recovers the files selected
File[] files;
try{
files = filesChooser.getSelectedFiles();
}catch(NullPointerException exc){
error.setText("No selected file");
throw new Md5Exception("No selected file : " + exc.getMessage());
}
for(int i = 0; i < files.length; i++){
String fileName = files[i].getAbsolutePath() ;
//Creation du md5 en java
String output;
try{
output = CreateMD5.getMD5(fileName);
}catch(Md5Exception e1){
error.setText("Error creating the MD5");
throw new Md5Exception("Error creating the MD5 : " + e1.getMessage());
}
/*Writing the md5 file
remove the extension of the original file if there is*/
String path;
if(files[i].getAbsolutePath().lastIndexOf(".") == -1){
path = files[i].getAbsolutePath() + ".md5";
}else {
String nomFichierSansExt = files[i].getAbsolutePath().substring(0, files[i].getAbsolutePath().lastIndexOf(".")) ;
path = nomFichierSansExt + ".md5";
}
File file = new File(path);
try {
if (!file.exists()){
// File Creation
file.createNewFile();
}
FileWriter writer = new FileWriter(file, true);
writer.write(output);
writer.close();
} catch (Exception ex) {
error.setText("Impossible to create MD5");
throw new Md5Exception("Impossible to create MD5 : " + ex.getMessage());
}
}
}
});
}