Class JFileChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JFileChooser extends JComponent implements Accessible
Emulator for JFileChooser. Emulator-only host (no surrogate): showOpenDialog composes an internal modal JDialog hosting a Vaadin Upload, parks the calling virtual thread via the JDialog modal machinery, and returns APPROVE_OPTION / CANCEL_OPTION once the user uploads + confirms (or cancels). showSaveDialog picks a name, hands back a per-session temp target via getSelectedFile(), and opens the synthetic download affordance. Selection getters return java.io.Files pointing at per-session temp files. Transfer mechanics are shared with FileDialog via BrowserFileTransfer.
See Also:
  • Field Details

  • Constructor Details

    • JFileChooser

      public JFileChooser()
    • JFileChooser

      public JFileChooser(String currentDirectoryPath)
    • JFileChooser

      public JFileChooser(File currentDirectory)
  • Method Details

    • showOpenDialog

      public int showOpenDialog(Component parent)
    • showSaveDialog

      public int showSaveDialog(Component parent)
    • showDialog

      @Deprecated public int showDialog(Component parent, String approveButtonText)
      Deprecated.
      triage the call site to showOpenDialog(Component) (the app reads the file) or showSaveDialog(Component) (the app writes it) — setApproveButtonText(String) keeps the custom label. The deprecation is deliberate divergence from the JDK, and is what makes an untriaged call site visible at compile time rather than only when someone walks that path.
      Unsupported in the browser, always throws — the sole throw on this class (R_match_swing_errors throw-trigger case (4), D_showdialog_throws). CUSTOM_DIALOG declares no LOAD/SAVE direction, and the two are different browser mechanisms that must be committed before the dialog opens, so no default is defensible: mapping it to LOAD silently produces an unreachable file whenever the app was naming an output. Nothing is mutated before the throw — the call is a no-op plus an exception. setDialogType(CUSTOM_DIALOG) itself stays faithful and round-trips; only the show is refused.
      Throws:
      IllegalStateException - always, carrying the triage rule.
    • getSelectedFile

      public File getSelectedFile()
    • setSelectedFile

      public void setSelectedFile(File file)
    • getSelectedFiles

      public File[] getSelectedFiles()
    • setSelectedFiles

      public void setSelectedFiles(File[] selectedFiles)
    • isMultiSelectionEnabled

      public boolean isMultiSelectionEnabled()
    • setMultiSelectionEnabled

      public void setMultiSelectionEnabled(boolean b)
    • getCurrentDirectory

      public File getCurrentDirectory()
    • setCurrentDirectory

      public void setCurrentDirectory(File dir)
    • getFileSelectionMode

      public int getFileSelectionMode()
    • setFileSelectionMode

      public void setFileSelectionMode(int mode)
    • isFileSelectionEnabled

      public boolean isFileSelectionEnabled()
    • isDirectorySelectionEnabled

      public boolean isDirectorySelectionEnabled()
    • getDialogTitle

      public String getDialogTitle()
    • setDialogTitle

      public void setDialogTitle(String dialogTitle)
    • getDialogType

      public int getDialogType()
    • setDialogType

      public void setDialogType(int dialogType)
    • getFileFilter

      public FileFilter getFileFilter()
    • setFileFilter

      public void setFileFilter(FileFilter filter)
    • addChoosableFileFilter

      public void addChoosableFileFilter(FileFilter filter)
    • removeChoosableFileFilter

      public boolean removeChoosableFileFilter(FileFilter f)
    • resetChoosableFileFilters

      public void resetChoosableFileFilters()
    • getChoosableFileFilters

      public FileFilter[] getChoosableFileFilters()
    • isAcceptAllFileFilterUsed

      public boolean isAcceptAllFileFilterUsed()
    • setAcceptAllFileFilterUsed

      public void setAcceptAllFileFilterUsed(boolean b)
    • isFileHidingEnabled

      public boolean isFileHidingEnabled()
    • setFileHidingEnabled

      public void setFileHidingEnabled(boolean b)
    • getAccessory

      public JComponent getAccessory()
    • setAccessory

      public void setAccessory(JComponent newAccessory)
      Parameters:
      newAccessory - the accessory component. Typed vaadinx.swing, not javax.swing: the JDK declares this signature, so per R_no_vaadin_in_api limb 1 it must speak the emulator's types. It took the JDK type until D_reverse_fanout_rows, which made the method impossible to call from import-swapped code at all — a migrator's JPanel is a vaadinx.swing.JPanel.
    • getFileView

      public FileView getFileView()
    • setFileView

      public void setFileView(FileView fileView)
    • getControlButtonsAreShown

      public boolean getControlButtonsAreShown()
    • setControlButtonsAreShown

      public void setControlButtonsAreShown(boolean b)
    • getApproveButtonText

      public String getApproveButtonText()
    • setApproveButtonText

      public void setApproveButtonText(String approveButtonText)
    • getApproveButtonToolTipText

      public String getApproveButtonToolTipText()
    • setApproveButtonToolTipText

      public void setApproveButtonToolTipText(String toolTipText)
    • getApproveButtonMnemonic

      public int getApproveButtonMnemonic()
    • setApproveButtonMnemonic

      public void setApproveButtonMnemonic(int mnemonic)
    • setApproveButtonMnemonic

      public void setApproveButtonMnemonic(char mnemonic)
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Component