Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java FileFilter problem

  • 26-03-2004 03:28PM
    #1
    Closed Accounts Posts: 41


    I am using JFilechooser and i created my own filefilter class which extends FileFilter. but when i pass it using addCoosableFileFilter() it comes back as just an interface instantiation, so all my cutom methods i made in my class don't work. using the getFileFilter() meathod, where am i going wrong???????

    can any one help????


Comments

  • Registered Users, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


    slap up your code,dork.


  • Closed Accounts Posts: 41 the_funkyguy


    /*
    EXAMPLE FILE FILTER
    */
    ExampleFileFilter filter3 = new ExampleFileFilter();
    filter3.addExtension("wav");
    filter3.setDescription("WAV(*.wav)");
    chooser.setFileFilter(filter3);
    chooser.addChoosableFileFilter(filter3);

    /*
    FILE FILTER CALL
    */
    String extention = chooser.getFileFilter().getExtention();

    that line gives me an error saying
    cannot resolve symbol
    symbol : meathod getExtention()
    location : class javax.swing.filechooser.FileFilter

    String extention = chooser.getFileFilter().getExtention();



  • Closed Accounts Posts: 41 the_funkyguy


    which is pretty much what i described but since you insisted Karoma


  • Registered Users, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


    not really. javax.swing.JFileChooser ... but then, you probably have a special setup with "meathods" and what not :) did you try instantiating xFileChoosers, where xFileChooser implements the interface... ? i can't tell anything from that bit of code..


    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html#JFileChooser(javax.swing.filechooser.FileSystemView)

    http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
    + source

    might help..


    edit: dork!


  • Closed Accounts Posts: 7 dicey


    Originally posted by the_funkyguy

    /*

    FILE FILTER CALL
    */
    String extention = chooser.getFileFilter().getExtention();

    that line gives me an error saying
    cannot resolve symbol
    symbol : meathod getExtention()
    location : class javax.swing.filechooser.FileFilter

    String extention = chooser.getFileFilter().getExtention();


    Of course it doesn't work! You need to cast it to be able to call your methods.

    Use
    String extension = ((ExampleFileFilter)chooser.getFileFilter()).getExtension();


  • Advertisement
Advertisement