2012-02-14 1 views
2

GUI를 여는 Java 에이전트가 있습니다. 에이전트가 완료되면 GUI는 계속 열려 있습니다. 에이전트를 다시 시작하거나 다른 에이전트를 시작할 때마다 동일한 GUI를 다시 사용하려고합니다.에이전트 호출간에 GUI (JFrame) 공유

열려있는 GUI를 감지하거나 에이전트간에 참조를 공유 할 수있는 방법이 있습니까?

답변

4

당신은

/** 
    * 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() 
+0

는 것을 실제로 로터스 노츠와 맥락에서 작동합니까있다 생성 된 모든 인스턴스를 통해 윈도우 클래스를 사용하고 반복 할 수 있습니까? 에이전트는 일반적으로 별개의 개체입니다. –

+1

@ Simon O'Doherty 나는 에이전트와 아무 관련이 없다고 생각합니다. 에이전트는 당신이 caled 한 오브젝트를 반환합니다. (Stas + 1) – mKorbel

+0

지금 시도 중입니다. 나는 프레임을 찾는다. 그러나 프레임의 처분은 호출되지 않습니다 (적어도 이음새가 너무 작음). 그래서 저는 기존 프레임을 닫고 있습니다. 그게 잘 작동하는 것 같아요. –

관련 문제