public class pro extends JFrame {
JTextField f;
java实验2(String s){
f=new JTextField(20);
setLayout(new FlowLayout());
this.setBounds(100,100,400,400);
this.add(f);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
B b=new B();
this.addMouseMotionListener(b);
}
//内部类
class B implements MouseMotionListener{
public void mouseMoved(MouseEvent e){}
public void mouseDragged(MouseEvent e){
f.setText((e.getX()+":"+e.getY()));
}
}
public static void main(String[] args){
new pro("我的第二个窗口");
}
}