Ⅰ 在java事件中。WindowEvent与WindowListener的区别是什么
Event就是事件,listener就是监听器,用于监听事件,即当发生某个事件时触发一些操作。
事件监听机制如下:
监听源比如一个按钮,调用addMouseListener,为其自身添加一个鼠标监听器,那么在该按钮上发生的相关鼠标事件比如鼠标按下,松开等将通知到该监听器,同时回调该监听器的相应方法。UI程序也是通过这样的方式来处理这些界面事件的。
同样的道理,WindowEvent和WindowListener你应该可以明白是做什么的了,就是窗口事件和窗口事件的监听器。窗口事件就比如窗口最大化最小化之类。
Ⅱ java中如何建立鼠标事件
importjavax.swing.*;
importjava.awt.event.*;
publicclassExample6_,MouseListener,WindowListener
{
JFramewin;
JTextFieldtext;
publicstaticvoidmain(String[]args)
{
_9w=newExample6_9();
w.toWin();
}
publicvoidtoWin()
{
win=newJFrame("实现三个接口的事例");
win.setSize(300,200);
win.setVisible(true);
win.add(newJLabel("单击并拖拽鼠标"));
text=newJTextField(30);
win.add(text,"South");
win.addMouseMotionListener(this);
win.addMouseListener(this);
win.addWindowListener(this);
}
publicvoidmouseDragged(MouseEvente)
{
Strings="拖曳鼠标:X="+e.getX()+"Y="+e.getY();
text.setText(s);
}
publicvoidmouseEntered(MouseEvente)
{
Strings="鼠标进入";
text.setText(s);
}
publicvoidmouseExited(MouseEvente)
{
Strings="鼠标离开";
text.setText(s);
}
publicvoidwindowClosing(WindowEvente)
{
System.exit(0);
}
publicvoidmouseMoved(MouseEvente){}
publicvoidmouseClicked(MouseEvente){}
publicvoidmousePressed(MouseEvente){}
publicvoidmouseReleased(MouseEvente){}
publicvoidwindowOpened(WindowEvente){}
publicvoidwindowIconified(WindowEvente){}
publicvoidwindowDeiconified(WindowEvente){}
publicvoidwindowClosed(WindowEvente){}
publicvoidwindowActivated(WindowEvente){}
publicvoidwindowDeactivated(WindowEvente){}
}
Ⅲ java中SWT鼠标单击事件监听器
为什么不能满足?
mouseUp就是按下之后被释放,mouseDown是按下去还没有释放。
你可以结合Control的bound和location来计算按下和释放时的位置来确定是否进行必要的事件处理。
Ⅳ javacript的window事件有哪些~
window函数:
.confirm()
.prompt()
.navigate()
.setInterval()
.setTimeout()
.clearInterval()
.clearTimerout()
.moveTo()
.resizeTo()
.open()
.showModalDialog()
.showModelessDialog()
window事件:
onload 发生在页面下载并装载完成之后发生。
unonload
onbeforeUnload="window.event.returnValue()"
onKeypress
window的对象
event:
altkey, shiftkey,ctrlkey
clientx,clienty
offsetX,offsetY
screenx,screeny
x,y
returnValue(false时取消处理。)
cancelBubble(可以取消窗口对事件的处理)
srcElement
keyCode
button(1-鼠标左按钮。。。) screen
navigate
location
frames parent top
parent:父窗口
window.parent.frames[1].location.reload();
parent["framename"].location.reload();
top:最顶层的窗口
clipboard
history
document 参考: http://www.cnblogs.com/davyjiang/articles/956093.html
Ⅳ java中WindowEvent e是什么意思呢
指示窗口状态改变的低级别事件。当打开、关闭、激活、停用、图标化或取消图标化 Window 对象时,或者焦点转移到 Window 内或移出 Window 时,由 Window 对象生成此低级别事件。
该事件被传递给每一个使用窗口的 addWindowListener 方法注册以接收这种事件的 WindowListener 或 WindowAdapter 对象。(WindowAdapter 对象实现 WindowListener 接口。)发生事件时,所有此类侦听器对象都将获得此 WindowEvent。
Ⅵ java 如何编写JFrame窗体右上角红色打叉关闭按钮的事件
在你JFrame的构造函数里,添加如下代码即可。
实际上就是添加一个对窗口动内作的监听程序代码段容
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});