Search code examples
javaswingjframejdialog

Make a JDialog always on top of parent (JFrame) but user still can interact with parent


I'm working on building a text editor program like NotePad. I want to make FindDialog always on top of MainFrame but user still can edit the text at JTextArea in MainFrame as NotePad.

Please help me!!!

I have used method jdialog.setModal(true). It make dialog always on top of parent but user can't edit the text at parent.

Edit: method setAlwaysOnTop() make dialog on top of all windows (include browsers,other programs..) so i can't use it


Solution

  • I have detected that we can use super(parent) to achieve this.

    class MyDialog extends JDialog {
    
        public MyDialog(JFrame parent) {
            super(parent);
        }
    
        /* Other codes */
    
    }