gpt4 book ai didi

java - 在代理调用之间共享 GUI (JFrame)

转载 作者:行者123 更新时间:2023-11-30 07:28:19 25 4
gpt4 key购买 nike

我有一个可以打开 GUI 的 Java 代理。代理完成后,GUI 保持打开状态。每当我再次启动代理或启动另一个代理时,我都想再次使用相同的 GUI。

有没有办法检测打开的 GUI 或在代理之间共享引用?

最佳答案

您可以使用 Window 类并遍历所有创建的实例

   /**
* Returns an array of all {@code Window}s, both owned and ownerless,
* created by this application.
* If called from an applet, the array includes only the {@code Window}s
* accessible by that applet.
* <p>
* <b>Warning:</b> this method may return system created windows, such
* as a print dialog. Applications should not assume the existence of
* these dialogs, nor should an application assume anything about these
* dialogs such as component positions, <code>LayoutManager</code>s
* or serialization.
*
* @see Frame#getFrames
* @see Window#getOwnerlessWindows
*
* @since 1.6
*/
public static Window[] getWindows()

框架也有

public static Frame[] getFrames()

关于java - 在代理调用之间共享 GUI (JFrame),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9276871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com