Bringing JFileChooser on top of all windows

后端 未结 3 1073
不知归路
不知归路 2020-11-22 04:14

I seem to have a problem with my very simple implementation of a file chooser dialogue that requires me to minimize Netbeans each time in order to get to it, and it gets pre

3条回答
  •  别跟我提以往
    2020-11-22 04:40

    I'm not sure what your problem actually is (it's probably your Netbeans.... who knows), but have you tried overriding the createDialog method?

    Example:

    JFileChooser fc = new JFileChooser() {
       @Override
       protected JDialog createDialog(Component parent) throws HeadlessException {
           // intercept the dialog created by JFileChooser
           JDialog dialog = super.createDialog(parent);
           dialog.setModal(true);  // set modality (or setModalityType)
           return dialog;
       }
    };
    

    This is merely a hack solution, you should not need to do that ordinarily.

提交回复
热议问题