Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java FileFilter problem

Options
  • 26-03-2004 3: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 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 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