GXT 的弹出窗口的按ESC键关闭
程序员文章站
2024-01-16 14:08:28
...
写一个SuperWindow 继承自 GXT的window 类;
public class SuperWindow extends Window {
private I18N i18N;
public SuperWindow() {
i18N = (I18N) Registry.get(ConstantUtil.I18N);
this.escCloseWindow();
setHeading("<strong>"+"按ESC键退出"+"。</strong>");
}
private void escCloseWindow() {
this.addListener(Events.OnKeyPress, new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
int code = ce.getKeyCode();
if (code == KeyCodes.KEY_ESCAPE){
// close();
hide();
}
}
});
}
自己定义的窗口继承自SuperWindow 就可以实现按ESC键退出窗口了。
public class SuperWindow extends Window {
private I18N i18N;
public SuperWindow() {
i18N = (I18N) Registry.get(ConstantUtil.I18N);
this.escCloseWindow();
setHeading("<strong>"+"按ESC键退出"+"。</strong>");
}
private void escCloseWindow() {
this.addListener(Events.OnKeyPress, new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
int code = ce.getKeyCode();
if (code == KeyCodes.KEY_ESCAPE){
// close();
hide();
}
}
});
}
自己定义的窗口继承自SuperWindow 就可以实现按ESC键退出窗口了。
上一篇: Alwayson 基本概念