下面程序中,在主窗口单击鼠标后,就会生成一个新窗口。
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=getlnsets();
setSize(insets, left+insets. right+150,
insets, top+insets. bottom+150);
this. addMouseListener(MouseEvent Handler());
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=new java3();
m. setLocation(x, y);
m. show();
static public void main(String[] args)
(new java3()), show();