图标化的JFrame显示在win 7任务栏上的模态JDialog后面,单击

问题描述

|| 我最初在Win XP上开发了以下代码。当您单击XP任务栏中的程序图标时,父框架保持图标化,并且jdialog返回焦点,这是我想要的行为。但是,当在Win 7上单击程序的任务栏图标时,父JFrame会将其状态更改回“正常”并显示在应用程序模式jdialog的后面。我尝试重写JFrame的setExtendedState()方法拦截框架的状态变化,但是没有运气。 是否有解决方法,还是我需要解决的逻辑缺陷?
import java.awt.*;

import javax.swing.jdialog;
import javax.swing.JFrame;

public class TestLogin extends JFrame {

public TestLogin() {
    this.setSize(300,300);
    iconify(this);
    setLocationRelativeto(null);
    this.setTitle(\"I\'m a Frame!\");
    this.setVisible(true);
    LoginScreen login = new LoginScreen(this);
}

public static void main(String [] args) {

    TestLogin frame = new TestLogin();  
}

public static void iconify(Frame frame) {
    int state = frame.getExtendedState();

    // Set the iconified bit
    state |= Frame.ICONIFIED;

    // Iconify the frame
    frame.setExtendedState(state);
}

public static void deiconify(Frame frame) {
    int state = frame.getExtendedState();

    // Clear the iconified bit
    state &= ~Frame.ICONIFIED;
    // Deiconify the frame
    frame.setExtendedState(state);
}


public class LoginScreen extends jdialog {

    private JFrame root;

    public LoginScreen(JFrame root) {
        super(root);
        this.root = root;
        setLocationRelativeto(null);
        this.setTitle(\"I\'m a Dialog!\");
        setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
        this.setSize(200,200);
        setVisible(true);
    }
}
}
    

解决方法

        它看起来像Java范例中的“编写一次,随处运行”中的错误。如果要包括Windows 7,则可以联系oracle并填写错误报告。 问候, 斯特凡     

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...