javax.swing.JFileChooser.setDialogType()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中javax.swing.JFileChooser.setDialogType()方法的一些代码示例,展示了JFileChooser.setDialogType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFileChooser.setDialogType()方法的具体详情如下:
包路径:javax.swing.JFileChooser
类名称:JFileChooser
方法名:setDialogType

JFileChooser.setDialogType介绍

暂无

代码示例

代码示例来源:origin: cmusphinx/sphinx4

static public void getFilename(String title, int type) {
  int returnVal;
  fileChooser.setDialogTitle(title);
  fileChooser.setCurrentDirectory(file);
  fileChooser.setDialogType(type);
  if (type == JFileChooser.OPEN_DIALOG) {
    returnVal = fileChooser.showOpenDialog(jframe);
  } else {
    returnVal = fileChooser.showSaveDialog(jframe);
  }
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    file = fileChooser.getSelectedFile();
    filename = file.getAbsolutePath();
    prefs.put(FILENAME_PREFERENCE, filename);
  }
}

代码示例来源:origin: plantuml/plantuml

private void displayDialogChangeDir() {
  final JFileChooser chooser = new JFileChooser();
  chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
  chooser.setDialogTitle("Directory to watch:");
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  chooser.setAcceptAllFileFilterUsed(false);
  final String currentPath = prefs.get(KEY_DIR, ".");
  chooser.setCurrentDirectory(new File(currentPath));
  Log.info("Showing OpenDialog");
  final int returnVal = chooser.showOpenDialog(this);
  Log.info("Closing OpenDialog");
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    final File dir = chooser.getSelectedFile();
    changeDir(dir);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-util

if (approveButtonText != null) {
  chooser.setApproveButtonText(approveButtonText);
  chooser.setDialogType(javax.swing.JFileChooser.CUSTOM_DIALOG);

代码示例来源:origin: RaiMan/SikuliX2

String btnApprove = "Select";
if (mode == FileDialog.SAVE) {
 fchooser.setDialogType(JFileChooser.SAVE_DIALOG);
 btnApprove = "Save";

代码示例来源:origin: org.netbeans.api/org-openide-util-ui

if (approveButtonText != null) {
  chooser.setApproveButtonText(approveButtonText);
  chooser.setDialogType(javax.swing.JFileChooser.CUSTOM_DIALOG);

代码示例来源:origin: org.brunocvcunha.inutils4j/inutils4j

public static File chooseDirOpen(File dir, String title) {
 JFileChooser chooser = new JFileChooser();
 chooser.setCurrentDirectory(dir);
 chooser.setDialogTitle(title);
 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
 chooser.setDialogType(JFileChooser.OPEN_DIALOG);
 chooser.showSaveDialog(null);
 File saveTo = chooser.getSelectedFile();
 return saveTo;
}

代码示例来源:origin: net.sf.ingenias/editor

@Override
public void actionPerformed(ActionEvent e) {
  chooser.setDialogType(chooser.OPEN_DIALOG);
  chooser.showOpenDialog(null);
  if (chooser.getSelectedFile()==null)
    JOptionPane.showMessageDialog(workspaceChange, 
        "A directory has to be chosen",
        "No directory selected",JOptionPane.ERROR_MESSAGE);
  else
    directory.setText(chooser.getSelectedFile().toString());
}

代码示例来源:origin: org.brunocvcunha.inutils4j/inutils4j

public static File chooseFile(File dir, String title, int selectionMode) {
 JFileChooser chooser = new JFileChooser();
 chooser.setCurrentDirectory(dir);
 chooser.setDialogTitle(title);
 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 chooser.setDialogType(JFileChooser.SAVE_DIALOG);
 chooser.showSaveDialog(null);
 File saveTo = chooser.getSelectedFile();
 return saveTo;
}

代码示例来源:origin: org.brunocvcunha.inutils4j/inutils4j

public static File chooseFileOpen(File dir, String title) {
 JFileChooser chooser = new JFileChooser();
 chooser.setCurrentDirectory(dir);
 chooser.setDialogTitle(title);
 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 chooser.setDialogType(JFileChooser.OPEN_DIALOG);
 chooser.showSaveDialog(null);
 File saveTo = chooser.getSelectedFile();
 return saveTo;
}

代码示例来源:origin: org.brunocvcunha.inutils4j/inutils4j

public static File chooseFileSave(File dir, String title) {
 JFileChooser chooser = new JFileChooser();
 chooser.setCurrentDirectory(dir);
 chooser.setDialogTitle(title);
 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
 chooser.setDialogType(JFileChooser.SAVE_DIALOG);
 chooser.showSaveDialog(null);
 File saveTo = chooser.getSelectedFile();
 return saveTo;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler

private static JFileChooser getSnapshotDirectoryChooser() {
  if (snapshotDirectoryChooser == null) {
    snapshotDirectoryChooser = new JFileChooser();
    snapshotDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    snapshotDirectoryChooser.setMultiSelectionEnabled(false);
    snapshotDirectoryChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    snapshotDirectoryChooser.setDialogTitle(Bundle.HeapDumpAction_DirectoryDialogCaption());
  }
  return snapshotDirectoryChooser;
}

代码示例来源:origin: nroduit/Weasis

protected JFileChooser getOpenFileChooser() {
  JFileChooser fileChooser = new JFileChooser(getLastFolder());
  fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
  return fileChooser;
}

代码示例来源:origin: stackoverflow.com

JFileChooser fc = new JFileChooser();
String title = isLoad ? "Load the game" : "Save the game";
int type = isLoad ? JFileChooser.OPEN_DIALOG:JFileChooser.SAVE_DIALOG;
fc.setDialogType(type);
fc.showDialog(null, title);

代码示例来源:origin: es.ucm.fdi.gaia/jCOLIBRI

public File askForFile(){
 JFileChooser jfc = new JFileChooser();
 jfc.setDialogType(JFileChooser.SAVE_DIALOG);
 jfc.setDialogTitle("Choose Export File");
 jfc.setAcceptAllFileFilterUsed(false);
 jfc.setFileFilter(new SimpleFileFilter("png","Portable N Graphics (*.png)"));
 
 int retval = jfc.showSaveDialog(this);
 if (retval != JFileChooser.APPROVE_OPTION)
   return null;
 return jfc.getSelectedFile();
}

代码示例来源:origin: edu.toronto.cs.savant/savant-core

@Override
  public void actionPerformed(ActionEvent e) {
    fc.setDialogType(JFileChooserDialogType);
    int result = fc.showDialog(null, null);
    if (result == JFileChooser.CANCEL_OPTION || result == JFileChooser.ERROR_OPTION) {
      return;
    }
    setPath(fc.getSelectedFile().getAbsolutePath());
  }
});

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

@Override
  public void actionPerformed(ActionEvent e) {
    fc.setDialogType(JFileChooserDialogType);
    int result = fc.showDialog(null, null);
    if (result == JFileChooser.CANCEL_OPTION || result == JFileChooser.ERROR_OPTION) {
      return;
    }
    setPath(fc.getSelectedFile().getAbsolutePath());
  }
});

代码示例来源:origin: nroduit/Weasis

protected JFileChooser getSaveFileChooser() {
  JFileChooser fileChooser = new JFileChooser(getLastFolder());
  fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
  fileChooser.setAcceptAllFileFilterUsed(false);
  return fileChooser;
}

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

public static JFileChooser createSaveFileChooser(
  final IPreferences preferences,
  final ISaveFileChooserConfiguration configuration) {
 final JFileChooser fileChooser = createFileChooser(preferences, configuration);
 if (configuration.getPresetFile() != null) {
  fileChooser.setSelectedFile(configuration.getPresetFile());
 }
 fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
 fileChooser.setSelectedFile(configuration.getPresetFile());
 return fileChooser;
}

代码示例来源:origin: org.databene/databene-commons

public SwingFileChooser(FileTypeSupport supportedTypes, FileOperation operation) {
  Assert.notNull(supportedTypes, "supportedTypes");
  Assert.notNull(operation, "operation");
  this.operation = operation;
  super.setFileSelectionMode(fileSelectionMode(supportedTypes));
  super.setDialogType(dialogType(operation));
}

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

public static JFileChooser createOpenFileChooser(
  final IPreferences preferences,
  final IOpenFileChooserConfiguration configuration) {
 final JFileChooser fileChooser = createFileChooser(preferences, configuration);
 final IAccessoryFactory accessoryFactory = configuration.getFileViewFactory();
 fileChooser.setAccessory(accessoryFactory.create(fileChooser));
 fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
 return fileChooser;
}

相关文章

JFileChooser类方法