2011-04-11 65 views
0

我想关闭一个弹出面板,点击一个锚点,但这个锚点可能在几个面板内,然后通过父母并不是一个好主意。GWT正确关闭弹出式面板?

我该如何获得锚点所在的弹出面板?

回答

2

将​​的变量传递给其他面板,怎么样?

public class PanelWithPopup extends Composite 
{ 
    FlowPanel thisPanel = new FlowPanel(); 
    PopupPanel popup = new PopupPanel(); 
    SomeOtherPanel otherPanel; 

    public PanelWithPopup() 
    { 
     // pass the popup panel to the SomeOtherPanel 
     otherPanel = new SomeOtherPanel(popup); 

     thisPanel.add(otherPanel); 
     initWidget(thisPanel); 
    } 
} 

public class SomeOtherPanel 
{ 
    PopupPanel popup; 

    public SomeOtherPanel(PopupPanel p) 
    { 
     this.popup = p; 
    } 

    void hidePopup() 
    { 
     popup.hide(); 
    } 
} 

或者,如果其他的板的主面板内限定(即,如果SomeOtherPanel是在PanelWithPopup内定义),可以直接访问PopupPanel popup