Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

File getBankFile( ){ // conducts a file choosing dialog showing onlydirectories

ID: 3612912 • Letter: F

Question

File getBankFile( ){

// conducts a file choosing dialog showing onlydirectories and .bnk files

// returns the chosen file (which may be a file that does notexist), OR returns null

//     a) if no file was chosen

//     b) if the file chosen did not have anextension of ,bnk

//    c) if the file chosen is not readable andwritable (whether it already exists or not)

1) Write a method that is passed a name and tells(returns) whether it ends with the 4 characters ".bnk"

2) What method in JFileChooser allows you to control whichfiles will be shown?

3) What is the full name of an abstract class that needsto be used in order to control which files will be shown by aJFileChooser?

Explanation / Answer

1) Write a method that is passed a name and tells(returns) whether it ends with the 4 characters ".bnk" public boolean accept(Stringname) {    returnname.length()>4 && name.substring(name.length()-4,name.length()).equals(".bnk"); } 2) What method in JFileChooser allows you to controlwhich files will be shown? You can add FileFilters throughaddChoosableFileFilter(FileFilterfilter). In addition, usesetAcceptAllFileFilterUsed(false) sothe JFileChooser does not allow theuser to choose any file. 3. Aspreviously mentioned, interface FileFilter allows you to control which files will beshown. 3. Aspreviously mentioned, interface FileFilter allows you to control which files will beshown.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote