首页 > 题库 > 学历提升 > 自学考试 > 自考本科 > 填空题

以下程序实现了MouseMotionListener接口。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public classTest28 ① MouseMotionListener{
private JFrame frame;
private JTextField tf;
public static void main(String args[j){
Test28 one=new Test28();
one.go();
}
public void go(){
frame = new JFrame("listener example");
Container contentPane= frame.getContentPane();
contentPane.add(new Label("drag the mouse"),BorderLayout.NORTH);
tf=newJTextField(30);
contentPane.add(tf,BorderLayout.SOUTH):
frame. ② ;
frame.setSize(300,300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void ③ (MouseEvent e){
String s="Mouse dragging: X="+e.getX)+"Y="+e.getY();
tf.setText(s);
}
public void mouseMoved (MouseEvent e){}
}


参考答案: 查看答案 查看解析 下载APP畅快刷题

相关知识点试题

相关试卷