![](/img/trans.png)
[英]How can I change this code so that when you enter localhost:9080/?say=hello, it outputs hello?
[英]When i close my fram from addMouseListener it say that this is incompatible type so with what can i change this?
我的代码dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING))
不起作用:
jTable1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int select = jTable1.getSelectedRow();
int choi = JOptionPane.showConfirmDialog(null, "Voulez Vous vraiment choisir ce client ?");
if(choi == 0){
Utile.idClient=jTable1.getModel().getValueAt(select, 0).toString();
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
}
}
});
由于您使用的是内部类, this
指向内部实例。 要获取外部实例,请使用:
MyFrame.this
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
“ this”是指MouseListener,而不是框架。
要找到活动窗口,您可以执行以下操作:
Window window = SwingUtilities.windowForCompoent( e.getComponent() );
dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.