public void chooseDriver ( final JFrame frm , final JTextField field ) { final JFileChooser chooser = new JFileChooser ( new File ( "." ) ) ; for ( final FileFilter ff : chooser . getChoosableFileFilters ( ) ) { chooser . removeChoosableFileFilter ( ff ) ; // clean choosable filters } // end of for chooser . setFileHidingEnabled ( false ) ; chooser . setDialogTitle ( "Chooser JDBC driver" ) ; chooser . setMultiSelectionEnabled ( false ) ; chooser . setFileFilter ( new JDBCDriverFileFilter ( ) ) ; final int choice = chooser . showOpenDialog ( frm ) ; if ( choice != JFileChooser . APPROVE_OPTION ) { return ; } // end of if // --- final File driverFile = chooser . getSelectedFile ( ) ; final String driverPath = driverFile . getAbsolutePath ( ) ; field . setForeground ( Color . BLACK ) ; field . setText ( driverPath ) ; try { model . setDriver ( JDBC . loadDriver ( driverFile ) ) ; // !! Side-effect conf . put ( "jdbc.driverPath" , driverPath ) ; updateConfig ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } // end of catch }
Chooses a JDBC driver .