black

登录

问答题

下面程序中,在主窗口单击鼠标后,就会生成一个新
窗口。
import java.awt.*;
import java.awt.event.*;
public class java3 extends Frame{
java3(){
super("java3");
addNotify();
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
Insets insets=getInsets();
setSize(insets.left+insets.right+150,
insets.top+insets.bottom+150);
this.addMouseListener(MouseEventHandler());
}
class MouseEventHandler implements MouseAda-
pter{
public void mousePresse(MouseEvent evt){
Rectangle bounds=getBounds();
int x=evt.getX()+bounds.x;
int y=evt.getY()十bounds.y;
java3 m=newjava3();
m.setLocation(x,y);
m.show();
}
}
static public void main(String[]args){
(new java3()).show();
}
}

【参考答案】

第1处:this.addMouseListener(new MouseEventHandler())
第2处:......

(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)

相关考题

判断题 银行可以通过建立客户档案的形式来实现对客户信息的收集与整理。

判断题 银行产品设计的技术主要是指银行产品的定价、利费率的设定。

问答题 本题是判断一个字符串“Tom”是否在另外一个字符串 “I am Tom,I am from China”中出现。 public class javal{ public static void main(String[]args){; strl="I am Tom,I am from China."; str2="Tom"; int i= ; if( ) System.out.println("\"+str2+"\"is in the string:\""+strl+"\""); else System.out.println("\""+str2+"\"is not in the string:\""+strl+"\""); } }

All Rights Reserved 版权所有©在线考试题库网(zxkao.com)

备案号:湘ICP备14005140号-7

经营许可证号:湘B2-20140064