[問答題] 下面程序中,在主窗口單擊鼠標(biāo)后,就會(huì)生成一個(gè)新窗口。 import java.awt.*; import java.awt.event.*;
[問答題] 下面程序中,在主窗口單擊鼠標(biāo)后,就會(huì)生成一個(gè)新窗口。
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 MouseAdapter
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(Strin
正確答案:第1處:this.addMouseListener(new MouseEventHandler()) 第2處:class MouseEventHandler extends MouseAdapter 第3處:public void mousePressed(MouseEvent evt)
參考解析:第1處參數(shù)應(yīng)為實(shí)例化對(duì)象;第2處繼承父類應(yīng)使用extends,implements實(shí)現(xiàn)的是接口;第3處單擊鼠標(biāo)后事件應(yīng)為mousePressed。
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。