【问题标题】:Java - How can a dialog be displayed at the same location it was closed?Java - 如何在关闭的同一位置显示对话框?
【发布时间】:2012-09-17 11:02:01
【问题描述】:

我有一个在 Java 中扩展 EscapeDialog 的对话框类。如何获取已关闭屏幕上的位置,并在用户再次打开对话框时显示在同一位置?

【问题讨论】:

    标签: java swing dialog escaping location


    【解决方案1】:

    您可以监听 windowClosing 事件并将对话位置保存在某处:内存中、磁盘上...

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              // save the dialog.getLocation()
            }
        });
    

    然后,下次打开对话框时,从保存位置读取位置并在显示之前调用dialog.setLocation()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-17
      • 1970-01-01
      • 1970-01-01
      • 2010-11-03
      • 2018-08-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多