1
我有一個應用程序,在一個com.extjs.gxt.desktop.client.Desktop放置幾個Windows。我需要附加一個偵聽器,它在調整大小時記錄每個窗口的大小。我看到兩個問題:調整窗口大小時需要通知的正確方法是什麼?
而當窗口大小,它們出現之前,新的大小實際上是施加給車窗被解僱移動事件被解僱,所以我不能從請求新的大小直接窗口。
無論窗口的實際大小如何,在我的偵聽器中接收到的WindowEvent都包含大小0x0。
有什麼我在這裏失蹤?
這裏是我的代碼附加:
protected void addWindowListeners(Window w,
String uid, WindowData windowData)
{
WindowChangeListener l = new WindowChangeListener(uid, windowData);
w.addWindowListener(l);
// Add this again since the default WindowListener doesn't support the Move event.
w.addListener(Events.Move, l);
}
而且監聽器類:
protected class WindowChangeListener
extends WindowListener
implements Listener<WindowEvent>
{
@Override
public void windowHide(WindowEvent we)
{
updateWindowData(we);
}
@Override
public void windowShow(WindowEvent we)
{
updateWindowData(we);
}
public void windowMove(WindowEvent we)
{
updateWindowData(we);
}
protected void updateWindowData(WindowEvent we)
{
// Here's the part that needs to get notified with the new size.
}
@Override
public void handleEvent(WindowEvent we)
{
if(we.getType() == Events.Move)
windowMove(we);
else
super.handleEvent(we);
}
}
感謝任何見解的人都有。我覺得我必須錯過簡單的東西。