Frage zum JFileChooser.



  • hallo, wie kann ich es anstellen, daß der filechooser in ein bestimmtes directory geht? also ich klicke auf einen knopf und der chooser öffnet sich. jetzt möchte ich, daß er gleich dateien aus einem bestimmten verzeichnis anzeigt.

    DANKE:)



  • Java-API
    JFileChooser
    ...
    public void setCurrentDirectory(File dir)
    Sets the current directory. Passing in null sets the file chooser to point to the user's home directory. If the file passed in as currentDirectory is not a directory, the parent of the file will be used as the currentDirectory. If the parent is not traversable, then it will walk up the parent tree until it finds a traversable directory, or hits the root of the file system.
    Parameters:
    dir - the current directory to point to
    See Also:
    getCurrentDirectory()



  • ok, hab mich etwas falsch ausgedrückt. ich habe ein programm, welches sich irgendwohin installieren lässt. der FC soll dann genau dieses verzeichnis anzeigen. also muß ich ja den pfad schon vorm FC wissen, damit er gleich dahin geht, richtig?

    DANKE:)



  • Richtig 😉


  • Mod

    ClassLoader.getSystemResource(...) ist die Lösung!


Anmelden zum Antworten