Фокус проблемы с модальных диалогов java7 на Mac OSX

Я проверял свинг-приложение, которое работает на апплете для Mac OSX.

Во время этой проверки я обнаружил следующие проблемы с модальными диалоговыми окнами:

When a dialog is open and is setModal(true) it blocks the content of the root window, but if you click somewhere on the root window, the dialog goes under it, but it should remain on the top of the root window. If the dialog has a JTextInputField it does not receive focus even when you click on it.

Поэтому я создал небольшую программу, чтобы показать проблему. Можете ли вы помочь мне понять, что здесь не так?

package com.macosx.tests;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class DialogExample extends JApplet{

    private static final long serialVersionUID = 1L;
    private JPanel panel;
    private JButton openDialogBtn;

    private void doStart() {
        panel = new JPanel();
        panel.setPreferredSize(new Dimension(500,500));

        openDialogBtn = new JButton("open dialog");
        openDialogBtn.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                ModalDialog dialog = new ModalDialog(panel, true);
                dialog.setVisible(true);
            }

        });
        panel.add(openDialogBtn);
        setContentPane(panel);
    }


    class ModalDialog extends JDialog {
        private static final long serialVersionUID = 1L;

        public ModalDialog(Component parent, boolean modal) {
            Dimension dimensionParentFrame = parent.getSize();
            setSize(new Dimension((parent == null) ? 300 : dimensionParentFrame.width / 2, 75));

            setModal(modal);
            setModalityType(ModalityType.APPLICATION_MODAL);

            JTextField txtField = new JTextField();
            add(txtField, BorderLayout.CENTER);
        }
    }


    @Override
    public void start() {
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    doStart();
                }
            });
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

Используйте приведенное выше для создания файла .jar (test.jar). Как только это будет сделано, создайте HTML-файл со следующим содержанием:

<html>
<head>
<title>Dialog test Applet</title>
</head>
<body>
<applet id="DialogTestApplet" height="800" width="600"
  code="com.macosx.tests.DialogExample"
  archive="test.jar">
</applet>
</div>
</body>
</html>

Когда это будет сделано, запустите HTML-файл. Вы увидите апплет с серым фоном и с кнопкой. Затем попробуйте:

click on the button to open the dialog. After that, click somewhere on the gray area: the dialog goes under the browser window but it should remain on the top, right? click on the button to open the dialog. After that click on the textfield of the dialog and try to write something: the textdialog does not receive focus.

Итак, что я здесь делаю не так? Может кто-нибудь с компьютером Mac проверить это, пожалуйста?

Спасибо

Технические характеристики:

java.vendor    Oracle Corporation
java.version   1.7.0_07
os.name        Mac OS X
os.version     10.7.4

browser        firefox 15

NOTE: please note that this is only happening when the applet runs on the browser and only on mac osx.

Ответы на вопрос(9)

Ваш ответ на вопрос