KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > swing > JFileChooser

javax.swing
Class JFileChooser

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JFileChooser
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
See Also:
Top Examples, Source Code

public boolean accept(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected AccessibleContext accessibleContext
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String ACCESSORY_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void addActionListener(ActionListener l)
See Also:
cancelSelection(), approveSelection()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void addChoosableFileFilter(FileFilter filter)
See Also:
setFileSelectionMode(int), resetChoosableFileFilters(), removeChoosableFileFilter(javax.swing.filechooser.FileFilter), getChoosableFileFilters()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void approveSelection()
See Also:
APPROVE_SELECTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int APPROVE_OPTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String APPROVE_SELECTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void cancelSelection()
See Also:
CANCEL_SELECTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CANCEL_OPTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String CANCEL_SELECTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void changeToParentDirectory()
See Also:
getCurrentDirectory()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected JDialog createDialog(Component parent)
                        throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int CUSTOM_DIALOG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String DIALOG_TITLE_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String DIALOG_TYPE_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int DIRECTORIES_ONLY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1518]Open file dialog
By anibal { at } letrasticas { dot } info on 2005/08/17 14:44:10  Rate
  public String getDir (  )  {  
     String directoryInit = "."; 
      
     JFileChooser gd = new JFileChooser ( "." ) ; 
     gd.setFileSelectionMode ( JFileChooser.FILES_ONLY ) ; 
     gd.showOpenDialog ( MainWindow ) ; 
     File selFile = gd.getSelectedFile (  ) ; 
     System.out.println ( gd.getSelectedFile (  ) .getName (  )  ) ; 
  
  
     return gd.getSelectedFile (  ) .getName (  ) ; 
    } 


public static final String DIRECTORY_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void ensureFileIsVisible(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int ERROR_OPTION
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int FILES_AND_DIRECTORIES
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int FILES_ONLY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String FILE_FILTER_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String FILE_HIDING_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String FILE_VIEW_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void fireActionPerformed(String command)
See Also:
EventListenerList
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileFilter getAcceptAllFileFilter()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public AccessibleContext getAccessibleContext()
See Also:
JComponent, Accessible
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JComponent getAccessory()
See Also:
setAccessory(javax.swing.JComponent)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ActionListener[] getActionListeners()
See Also:
removeActionListener(java.awt.event.ActionListener), addActionListener(java.awt.event.ActionListener)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getApproveButtonMnemonic()
See Also:
setApproveButtonMnemonic(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getApproveButtonText()
See Also:
showDialog(java.awt.Component, java.lang.String), setDialogType(int), setApproveButtonText(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getApproveButtonToolTipText()
See Also:
showDialog(java.awt.Component, java.lang.String), setDialogType(int), setApproveButtonText(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileFilter[] getChoosableFileFilters()
See Also:
resetChoosableFileFilters(), removeChoosableFileFilter(javax.swing.filechooser.FileFilter), addChoosableFileFilter(javax.swing.filechooser.FileFilter)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean getControlButtonsAreShown()
See Also:
setControlButtonsAreShown(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public File getCurrentDirectory()
See Also:
setCurrentDirectory(java.io.File)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getDescription(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getDialogTitle()
See Also:
setDialogTitle(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getDialogType()
See Also:
setDialogType(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean getDragEnabled()
See Also:
setDragEnabled(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileFilter getFileFilter()
See Also:
addChoosableFileFilter(javax.swing.filechooser.FileFilter), setFileFilter(javax.swing.filechooser.FileFilter)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getFileSelectionMode()
See Also:
setFileSelectionMode(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileSystemView getFileSystemView()
See Also:
setFileSystemView(javax.swing.filechooser.FileSystemView)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileView getFileView()
See Also:
setFileView(javax.swing.filechooser.FileView)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Icon getIcon(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getName(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public File getSelectedFile()
See Also:
setSelectedFile(java.io.File)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public File[] getSelectedFiles()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getTypeDescription(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public FileChooserUI getUI()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getUIClassID()
See Also:
UIDefaults.getUI(javax.swing.JComponent), JComponent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isAcceptAllFileFilterUsed()
See Also:
setAcceptAllFileFilterUsed(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isDirectorySelectionEnabled()
See Also:
getFileSelectionMode(), setFileSelectionMode(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isFileHidingEnabled()
See Also:
setFileHidingEnabled(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isFileSelectionEnabled()
See Also:
getFileSelectionMode(), setFileSelectionMode(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isMultiSelectionEnabled()
See Also:
setMultiSelectionEnabled(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isTraversable(File f)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFileChooser()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[462]File chooser
By ZillaFan37 on 2004/02/19 14:36:50  Rate
public static void main (  String args [  ]   )  
  {  
    File file = null ; 
    if  ( args.length  >  0 )  
     {  
       // allow a file to be specified via the command  
       // line  ( for testing )  
       file = new File ( args [ 0 ]  )  ; 
     }  
    else 
     {  
       // allow the user to browse for a file if one was not  
       // specified at the command line 
       JFileChooser jfc = new JFileChooser (  )  ; 
       int result = jfc.showOpenDialog ( null )  ; 
       if  ( result == jfc.CANCEL_OPTION )  
        {  
          System.exit (  0  )  ; 
        }  
       file = jfc.getSelectedFile (  )  ; 
     } 


public JFileChooser(File currentDirectory)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFileChooser(File currentDirectory,
                    FileSystemView fsv)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFileChooser(String currentDirectoryPath)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFileChooser(String currentDirectoryPath,
                    FileSystemView fsv)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public JFileChooser(FileSystemView fsv)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int OPEN_DIALOG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected String paramString()
See Also:
JComponent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void removeActionListener(ActionListener l)
See Also:
addActionListener(java.awt.event.ActionListener)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean removeChoosableFileFilter(FileFilter f)
See Also:
resetChoosableFileFilters(), getChoosableFileFilters(), addChoosableFileFilter(javax.swing.filechooser.FileFilter)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void rescanCurrentDirectory()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void resetChoosableFileFilters()
See Also:
removeChoosableFileFilter(javax.swing.filechooser.FileFilter), getChoosableFileFilters(), addChoosableFileFilter(javax.swing.filechooser.FileFilter)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int SAVE_DIALOG
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String SELECTED_FILES_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String SELECTED_FILE_CHANGED_PROPERTY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setAcceptAllFileFilterUsed(boolean b)
See Also:
setFileFilter(javax.swing.filechooser.FileFilter), getAcceptAllFileFilter(), isAcceptAllFileFilterUsed()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setAccessory(JComponent newAccessory)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setApproveButtonMnemonic(char mnemonic)
See Also:
getApproveButtonMnemonic()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setApproveButtonMnemonic(int mnemonic)
See Also:
getApproveButtonMnemonic()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setApproveButtonText(String approveButtonText)
See Also:
showDialog(java.awt.Component, java.lang.String), setDialogType(int), getApproveButtonText()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setApproveButtonToolTipText(String toolTipText)
See Also:
showDialog(java.awt.Component, java.lang.String), setDialogType(int), setApproveButtonText(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setControlButtonsAreShown(boolean b)
See Also:
CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY, getControlButtonsAreShown()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setCurrentDirectory(File dir)
See Also:
getCurrentDirectory()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setDialogTitle(String dialogTitle)
See Also:
getDialogTitle()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setDialogType(int dialogType)
See Also:
setApproveButtonText(java.lang.String), getDialogType(), IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setDragEnabled(boolean b)
See Also:
TransferHandler, JComponent.setTransferHandler(javax.swing.TransferHandler), getDragEnabled(), GraphicsEnvironment.isHeadless(), HeadlessException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setFileFilter(FileFilter filter)
See Also:
getFileFilter()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setFileHidingEnabled(boolean b)
See Also:
isFileHidingEnabled()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setFileSelectionMode(int mode)
See Also:
getFileSelectionMode(), IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setFileSystemView(FileSystemView fsv)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setFileView(FileView fileView)
See Also:
getFileView()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setMultiSelectionEnabled(boolean b)
See Also:
isMultiSelectionEnabled()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setSelectedFile(File file)
See Also:
getSelectedFile()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setSelectedFiles(File[] selectedFiles)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


protected void setup(FileSystemView view)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int showDialog(Component parent,
                      String approveButtonText)
               throws HeadlessException
See Also:
GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int showOpenDialog(Component parent)
                   throws HeadlessException
See Also:
showDialog(java.awt.Component, java.lang.String), GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[334]Display a selected file
By Anonymous on 2003/08/05 08:49:19  Rate
try 
               {  
     if ( filechooser.ShowOpenDialog ( null )  == JFileChooser.APPROVE_OPTION )  
       {  
       file = new BufferedReader ( new FileReader ( filechooser.getSelectedFile (  )  )  ) ; 
       plainText.setText ( "" ) ; 
          while (  ( temp = file.readLine (  )  )  != null )  {  
        plainText.setText ( plainText.getText (  ) +temp+"\n" ) ; 
        } //while 
        file.close (  ) ;     
        }  //if 
         }  //try 
       catch ( FileNotFoundException e )  
      {  
      JOptionPane.showMessageDialog 
                     ( null, "bad file name Try again" ) ; 
      }    
    }  
 //it will not accept the value null


public int showSaveDialog(Component parent)
                   throws HeadlessException
See Also:
showDialog(java.awt.Component, java.lang.String), GraphicsEnvironment.isHeadless()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void updateUI()
See Also:
JComponent
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags