为什么当父 JFrame 最小化时,这个无模式子 JDialog 没有最小化?
我的理解是,当父 JFrame 最小化时,它的子 JFrame 也会最小化,但在下面的简单示例中,这种情况不会发生(即,当 jframe 最小化时,子对话框保持可见)。我错过了什么吗?
public class Test
{
private JFrame f1;
private JDialog d2;
private void createAndShowGUI()
{
f1 = new JFrame("(parent frame)");
f1.addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
e.getWindow().dispose();
}
} );
f1.setBounds(32, 32, 300, 200);
d2 = new JDialog(f1, "child dialog" );
d2.setBounds(100, 100, 300, 200);
d2.setVisible( true );
f1.setVisible( true );
}
public static void main( String[] args )
{
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
Test test = new Test();
test.createAndShowGUI();
}
} );
}
}
谢谢!
My understanding is that when a parent JFrame is minimized then its children also are minimized but in the following dirt-simple example it doesn't happen (i.e. the child dialog stays visible when the jframe is minimized). Am I missing something?
public class Test
{
private JFrame f1;
private JDialog d2;
private void createAndShowGUI()
{
f1 = new JFrame("(parent frame)");
f1.addWindowListener( new WindowAdapter()
{
public void windowClosing( WindowEvent e )
{
e.getWindow().dispose();
}
} );
f1.setBounds(32, 32, 300, 200);
d2 = new JDialog(f1, "child dialog" );
d2.setBounds(100, 100, 300, 200);
d2.setVisible( true );
f1.setVisible( true );
}
public static void main( String[] args )
{
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
SwingUtilities.invokeLater( new Runnable()
{
public void run()
{
Test test = new Test();
test.createAndShowGUI();
}
} );
}
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试获取 Window[] 并将其全部关闭...也许这适用于每个操作系统。
Try getting Window[] and close them all... Maybe that works in every OS.