我刚刚学JAVA,在做一个文件管理工具时想用一个选择文件夹的控件,就像FileDloag一样的,但是FileDloag要在下面先输一个文件名才能返回,有没有想Windows里选文件夹的控件啊,在线等

解决方案 »

  1.   

    JFileDialogsetFileSelectionModepublic void setFileSelectionMode(int mode)
    Sets the JFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is JFilesChooser.FILES_ONLY.
    Parameters:
    mode - the type of files to be displayed:
    JFileChooser.FILES_ONLY
    JFileChooser.DIRECTORIES_ONLY
    JFileChooser.FILES_AND_DIRECTORIES
    Throws:
    IllegalArgumentException - if mode is an illegal file selection mode
    See Also:
    getFileSelectionMode()
      

  2.   

    因该有一个
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);