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

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

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

JFileChooser.cancelSelection介绍

暂无

代码示例

代码示例来源:origin: robotframework/SwingLibrary

@Override
  public void cancelSelection() {
    super.cancelSelection();
    cancelled = true;
  }
}

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

public void process(JFileChooser fileChooser) {
  fileChooser.cancelSelection();
 }
};

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
  chooser.cancelSelection();
}//GEN-LAST:event_cancelButtonActionPerformed

代码示例来源:origin: digital-preservation/droid

private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
  chooser.cancelSelection();
}//GEN-LAST:event_cancelButtonActionPerformed

代码示例来源:origin: openpreserve/jhove

@Override
  public void actionPerformed (ActionEvent e) 
  {
    // Exit the dialog and clear _tempDir
    _tempDir = null;
    _tempDirLabel.setText (tempDirDefault);
    chooser.cancelSelection ();
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

public void actionPerformed(ActionEvent e)
{
  if (editing)
  {
    cancelEdit();
  }
  else
  {
    getFileChooser().cancelSelection();
  }
}
public boolean isEnabled()

代码示例来源:origin: igvteam/igv

@Override
public void cancelSelection() {
  setSelectedFile(null);
  super.cancelSelection();
}

代码示例来源:origin: net.java.linoleum/application

@Override
public void cancelSelection() {
  returnValue = CANCEL_OPTION;
  if (dialog != null) {
    hide(dialog);
  }
  super.cancelSelection();
}

代码示例来源:origin: org.gephi/directory-chooser

@Override
public void actionPerformed(ActionEvent e) {
  getFileChooser().cancelSelection();
}
@Override

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

public static void main(String... args) {
  JFrame frame = new JFrame();
  frame.setVisible(true);
  final JFileChooser fchooser = new JFileChooser();

  new Thread() {
    @Override
    public void run() {
      try {
        Thread.sleep(5000);
      } catch (InterruptedException e) {}

      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          // This is run in EDT
          fchooser.cancelSelection();
        }
      });
    }
  } .start();

  fchooser.showOpenDialog(frame);
}

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

JFileChooser chooser = new JFileChooser();
chooser.addActionListener( new ActionListener() 
{
  public void actionPerformed(ActionEvent e) 
  {
    if( e.getActionCommand().equals("CancelSelection") )
    {
      chooser.cancelSelection();
    }
  }
} );

public void forceCancel()
{
  ActionEvent e = new ActionEvent(chooser, ActionEvent.ACTION_PERFORMED, "CancelSelection");
  fireActionPerformed(e);
}

public void fireActionPerformed( ActionEvent e )
{
  ActionListener[] listeners = chooser.getActionListeners();
 for( ActionListener listener : listeners )
 {
   listener.actionPerformed( e );
 }
}

代码示例来源:origin: org.gephi/directory-chooser

@Override
  public void keyPressed(KeyEvent evt) {
    showPopupCompletion = true;
    int keyCode = evt.getKeyCode();
    // #105801: completionPopup might not be ready when updateCompletions not called (empty text field)
    if (completionPopup != null && !completionPopup.isVisible()) {
      if (keyCode == KeyEvent.VK_ENTER) {
        File file = new File(filenameTextField.getText());
        if(file.exists() && file.isDirectory()) {
          setSelected(new File[] {file});
          fileChooser.approveSelection();
        }
      }
      
      if ((keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_DOWN) ||
        (keyCode == KeyEvent.VK_RIGHT && 
        (filenameTextField.getCaretPosition() >= (filenameTextField.getDocument().getLength() - 1)))) {
        updateCompletions();
      }
      
    }
    
    if(filenameTextField.isFocusOwner() && 
        (completionPopup == null || !completionPopup.isVisible()) &&
        keyCode == KeyEvent.VK_ESCAPE) {
      fileChooser.cancelSelection();
    }
  }
}

代码示例来源:origin: digital-preservation/droid

/**
 * Pops up a warning dialog if the selected file exists.
 */
@Override
public void approveSelection() {
  int confirm = JOptionPane.YES_OPTION;
  if (!getSelectedFile().exists() && getFileFilter().equals(csvFilter)) {
    final String filename = getSelectedFile().getName();
    String ext = FilenameUtils.getExtension(filename);
    if (!CSV_EXT.equals(ext)) {
      setSelectedFile(new File(getSelectedFile().getParentFile(), 
          filename + "." + CSV_EXT));
    }
  }
  if (getSelectedFile().exists()) {
    confirm = JOptionPane.showConfirmDialog(
        this,
        "The file you have selected already exists. Do you wish to overwrite it?",
        "File exists warning",
        JOptionPane.YES_NO_CANCEL_OPTION,
        JOptionPane.WARNING_MESSAGE
    );
  } 
  
  if (confirm == JOptionPane.YES_OPTION) {
    super.approveSelection();
  } else if (confirm == JOptionPane.CANCEL_OPTION) {
    super.cancelSelection();
  }
}

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

/**
 * Pops up a warning dialog if the selected file exists.
 */
@Override
public void approveSelection() {
  int confirm = JOptionPane.YES_OPTION;
  if (!getSelectedFile().exists() && getFileFilter().equals(csvFilter)) {
    final String filename = getSelectedFile().getName();
    String ext = FilenameUtils.getExtension(filename);
    if (!CSV_EXT.equals(ext)) {
      setSelectedFile(new File(getSelectedFile().getParentFile(), 
          filename + "." + CSV_EXT));
    }
  }
  if (getSelectedFile().exists()) {
    confirm = JOptionPane.showConfirmDialog(
        this,
        "The file you have selected already exists. Do you wish to overwrite it?",
        "File exists warning",
        JOptionPane.YES_NO_CANCEL_OPTION,
        JOptionPane.WARNING_MESSAGE
    );
  } 
  
  if (confirm == JOptionPane.YES_OPTION) {
    super.approveSelection();
  } else if (confirm == JOptionPane.CANCEL_OPTION) {
    super.cancelSelection();
  }
}

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

/**
 * Pops up a warning dialog if the selected file exists.
 */
@Override
public void approveSelection() {
  int confirm = JOptionPane.YES_OPTION;
  if (!getSelectedFile().exists() && getFileFilter().equals(filterFilter)) {
    final String filename = getSelectedFile().getName();
    String ext = FilenameUtils.getExtension(filename);
    if (!FILTER_EXT.equals(ext)) {
      setSelectedFile(new File(getSelectedFile().getParentFile(), 
          filename + "." + FILTER_EXT));
    }
  }
  if (getDialogType() == SAVE_DIALOG && getSelectedFile().exists()) {
    confirm = JOptionPane.showConfirmDialog(
        this,
        "The file you have selected already exists. Do you wish to overwrite it?",
        "File exists warning",
        JOptionPane.YES_NO_CANCEL_OPTION,
        JOptionPane.WARNING_MESSAGE
    );
  } 
  
  if (confirm == JOptionPane.YES_OPTION) {
    super.approveSelection();
  } else if (confirm == JOptionPane.CANCEL_OPTION) {
    super.cancelSelection();
  }
}

代码示例来源:origin: digital-preservation/droid

/**
 * Pops up a warning dialog if the selected file exists.
 */
@Override
public void approveSelection() {
  int confirm = JOptionPane.YES_OPTION;
  if (!getSelectedFile().exists() && getFileFilter().equals(filterFilter)) {
    final String filename = getSelectedFile().getName();
    String ext = FilenameUtils.getExtension(filename);
    if (!FILTER_EXT.equals(ext)) {
      setSelectedFile(new File(getSelectedFile().getParentFile(), 
          filename + "." + FILTER_EXT));
    }
  }
  if (getDialogType() == SAVE_DIALOG && getSelectedFile().exists()) {
    confirm = JOptionPane.showConfirmDialog(
        this,
        "The file you have selected already exists. Do you wish to overwrite it?",
        "File exists warning",
        JOptionPane.YES_NO_CANCEL_OPTION,
        JOptionPane.WARNING_MESSAGE
    );
  } 
  
  if (confirm == JOptionPane.YES_OPTION) {
    super.approveSelection();
  } else if (confirm == JOptionPane.CANCEL_OPTION) {
    super.cancelSelection();
  }
}

代码示例来源:origin: uk.gov.nationalarchives/droid-ui

/**
 * Pops up a warning dialog if the selected file exists.
 */
@Override
public void approveSelection() {
   if (getDialogType() == SAVE_DIALOG) {
    
    int confirm = JOptionPane.YES_OPTION;
    File selectedFile = getSelectedFile();
    if (selectedFile != null && selectedFile.exists()) {
      confirm = JOptionPane.showConfirmDialog(
          this, 
          "The file you have selected already exists. Do you wish to overwrite it?",
          "File exists warning",
          JOptionPane.YES_NO_CANCEL_OPTION,
          JOptionPane.WARNING_MESSAGE
      );
    }
    
    if (confirm == JOptionPane.YES_OPTION) {
      super.approveSelection();
    } else if (confirm == JOptionPane.CANCEL_OPTION) {
      super.cancelSelection();
    }
    
  } else {
    super.approveSelection();
  }
}

代码示例来源:origin: digital-preservation/droid

/**
 * Pops up a warning dialog if the selected file exists.
 */
@Override
public void approveSelection() {
   if (getDialogType() == SAVE_DIALOG) {
    
    int confirm = JOptionPane.YES_OPTION;
    File selectedFile = getSelectedFile();
    if (selectedFile != null && selectedFile.exists()) {
      confirm = JOptionPane.showConfirmDialog(
          this, 
          "The file you have selected already exists. Do you wish to overwrite it?",
          "File exists warning",
          JOptionPane.YES_NO_CANCEL_OPTION,
          JOptionPane.WARNING_MESSAGE
      );
    }
    
    if (confirm == JOptionPane.YES_OPTION) {
      super.approveSelection();
    } else if (confirm == JOptionPane.CANCEL_OPTION) {
      super.cancelSelection();
    }
    
  } else {
    super.approveSelection();
  }
}

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

cancelSelection();
cancelSelection();

相关文章

JFileChooser类方法