public static void setFolderBrowsingOnWidgets ( JTextField pathTextField , JButton browseButton ) { browseButton . addActionListener ( e -> { File lastFile = GuiUtilities . getLastFile ( ) ; File [ ] res = showOpenFolderDialog ( browseButton , "Select folder" , false , lastFile ) ; if ( res != null && res . length == 1 ) { String absolutePath = res [ 0 ] . getAbsolutePath ( ) ; pathTextField . setText ( absolutePath ) ; setLastPath ( absolutePath ) ; } } ) ; }
Adds to a textfield and button the necessary to browse for a folder .