Question

I have a weird problem with modal jdialog in windows xp. It seams i can't switch windows language with alt+shift while dialog is focused. I don't want parent frame to be accessible. Please help me.

public class MyDialog extends JDialog {
        public MyDialog(java.awt.Frame parent, boolean modal) {
            super(parent, modal);
            initComponents();
        }
        public static void main(String args[]) {   
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    MyDialog dialog = new MyDialog(new javax.swing.JFrame(), true);
                    dialog.setVisible(true);
                }
            });
        }
    }
Was it helpful?

Solution

I tried your example, without any success, Toolkit is never locked, Java6 on WinXp / Win2008

same for

  • AWT Frame with AWT Dialog

  • AWT Frame with Swing JDialog

  • Swing JFrame with Swing JDialog

  • Swing JFrame with AWT Dialog

based on code example

import javax.swing.JDialog;
import javax.swing.JFrame;

public class MyDialog {

    private JFrame frame = new JFrame();
    private JDialog dialog = new JDialog();

    public MyDialog() {
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        frame.setVisible(true);
        //dialog = new JDialog(frame, JDialog.ModalityType.TOOLKIT_MODAL);
        dialog = new JDialog(frame, true);
        dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        dialog.setModal(true);
        dialog.setSize(300, 200);
        dialog.setVisible(true);
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                MyDialog dialog = new MyDialog();
            }
        });
    }
}  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top