Claudio
Claudio

Reputation: 35

What are my options for parent when using JFileChooser?

I'm trying to show a window for file choosing as it follows:

public class XMLElementCounter() {

    public static void main(String[] args) {
        elementCounter();
    }
    
    static void elementCounter() {

        try {

            final FileChooser fc = new JFileChooser(defaultDirectory);
            int returnVal = fc.showOpenDialog(parent);
            
            ...

        }

}

First i declared the elementCounter directly in the main function and i called as parent fc, which showed the window as expected, but as i modularized it, it stopped showing anything. When i use null, it shows the screen behind every other window, which is annoying.

How can i know which is the parent i'm looking for, and where can i learn about it?

Upvotes: 0

Views: 59

Answers (0)

Related Questions