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

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

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

JFileChooser.getDialogType介绍

暂无

代码示例

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

private String getChooserType(JFileChooser fileChooser) {
  String message = "Chooser is in '";
  switch (fileChooser.getDialogType()) {
   case JFileChooser.OPEN_DIALOG:
    message += "open";
    break;
   case JFileChooser.SAVE_DIALOG:
    message += "save";
    break;
   default:
    message += "custom";
  }
  message += "' mode";
  return message;
 }
}

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

import java.io.File;
import javax.swing.JFileChooser;

public class MyFileChooser extends JFileChooser
{
  private static final long serialVersionUID = 1L;
  private String extension;

  public MyFileChooser(String currentDirectoryPath, String extension)
  {
    super(currentDirectoryPath);
    this.extension = extension;
  }

  @Override
  public File getSelectedFile()
  {
    File selectedFile = super.getSelectedFile();
    if(selectedFile != null && (getDialogType() == SAVE_DIALOG || getDialogType() == CUSTOM_DIALOG))
    {
      String name = selectedFile.getName();
      if(!name.contains(".")) selectedFile = new File(selectedFile.getParentFile(), name + "." + extension);
    }
    return selectedFile;
  }
}

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

private void doDialogTypeChanged(PropertyChangeEvent e)
{
  JFileChooser chooser= getFileChooser();
  approveButton.setText(getApproveButtonText(chooser));
  approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
  if (chooser.getDialogType() == JFileChooser.SAVE_DIALOG)
  {
    lookInLabel.setText(saveInLabelText);
  }
  else
  {
    lookInLabel.setText(lookInLabelText);
  }
}

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

public void process(JFileChooser fileChooser) {
 if (fileChooser.getDialogType() != expectedType) {
  AssertAdapter.fail(getChooserType(fileChooser));
 }
}

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

private void fireDialogTypeChanged(PropertyChangeEvent e) {
  JFileChooser chooser = getFileChooser();
  approveButton.setText(getApproveButtonText(chooser));
  approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
  // #107791: No mnemonics desirable on Mac 
  if (!Utilities.isMac()) {
    approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
  }
  if (chooser.getDialogType() == JFileChooser.SAVE_DIALOG) {
    lookInComboBoxLabel.setText(saveInLabelText);
  } else {
    lookInComboBoxLabel.setText(lookInLabelText);
  }
}

代码示例来源:origin: com.l2fprod.common/l2fprod-common-directorychooser

private void updateView(JFileChooser chooser) {
 if (chooser.getApproveButtonText() != null) {
  approveButton.setText(chooser.getApproveButtonText());
  approveButton.setMnemonic(chooser.getApproveButtonMnemonic());
 } else {
  if (JFileChooser.OPEN_DIALOG == chooser.getDialogType()) {
   approveButton.setText(openButtonText);
   approveButton.setToolTipText(openButtonToolTipText);
   approveButton.setMnemonic(openButtonMnemonic);
  } else {
   approveButton.setText(saveButtonText);
   approveButton.setToolTipText(saveButtonToolTipText);
   approveButton.setMnemonic(saveButtonMnemonic);
  }
 }
 cancelButton.setText(cancelButtonText);
 cancelButton.setMnemonic(cancelButtonMnemonic);
 newFolderButton.setText(newFolderText);
 newFolderButton.setToolTipText(newFolderToolTipText);
 newFolderButton.setVisible(((JDirectoryChooser)chooser).isShowingCreateDirectory());
 buttonPanel.setVisible(chooser.getControlButtonsAreShown());
 // ensure approve/cancel buttons have the same width
 approveButton.setPreferredSize(null);
 cancelButton.setPreferredSize(null);
 Dimension preferredSize = approveButton.getMinimumSize();
 preferredSize = new Dimension(Math.max(preferredSize.width, cancelButton
  .getPreferredSize().width), preferredSize.height);
 approveButton.setPreferredSize(preferredSize);
 cancelButton.setPreferredSize(preferredSize);    
}

代码示例来源:origin: com.jidesoft/jide-oss

if (JFileChooser.OPEN_DIALOG == chooser.getDialogType()) {
  _approveButton.setText(openButtonText);
  _approveButton.setToolTipText(openButtonToolTipText);

代码示例来源:origin: joel-costigliola/assertj-swing

/**
 * Returns the {@code String} representation of the given {@code Component}, which should be a {@code JFileChooser}.
 *
 * @param c the given {@code Component}.
 * @return the {@code String} representation of the given {@code JFileChooser}.
 */
@RunsInCurrentThread
@Override
@Nonnull protected String doFormat(@Nonnull Component c) {
 JFileChooser fileChooser = (JFileChooser) c;
 String format = "%s[name=%s, dialogTitle=%s, dialogType=%s, currentDirectory=%s, enabled=%b, visible=%b, showing=%b";
 return String.format(format, getRealClassName(c), quote(fileChooser.getName()),
            quote(fileChooser.getDialogTitle()), DIALOG_TYPES.get(fileChooser.getDialogType()),
            new StandardRepresentation().toStringOf(fileChooser.getCurrentDirectory()),
            fileChooser.isEnabled(),
            fileChooser.isVisible(), fileChooser.isShowing());
}

相关文章

JFileChooser类方法