Amit Gujjar
Amit Gujjar

Reputation: 681

How to display java swing component in front of Stage in javafx 2.1?

I am using swing component like JFileChooser, Joption in javafx application. But when i click on JFilechooser then this is being behinds of Application. How to solve this problem. Please give me some suggestion. Thanks in advance.

Upvotes: 1

Views: 482

Answers (1)

Andy Till
Andy Till

Reputation: 3511

You can create a subclass of JFileChooser and override the createDialog method and then return a dialog with always on top setting.

class AlwaysOnTopFileChooser extends JFileChooser {
    protected JDialog createDialog(Component parent) throws HeadlessException {
        JDialog dialog = super.createDialog(parent);
        dialog.setAlwaysOnTop(true);
        return dialog;
    }
}

You will need to fill in the required constructors etc.

Upvotes: 5

Related Questions