Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个在 Java 中扩展 EscapeDialog 的对话框类。如何在关闭的屏幕上获取位置,并在用户再次打开对话框时显示在同一位置?
您可以侦听 windowClosing 事件并将对话框位置保存在某处:内存中、磁盘上、...
frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { // save the dialog.getLocation() } });
然后,下次打开对话框时,从保存位置读取位置并dialog.setLocation()在显示之前调用。
dialog.setLocation()