首页 > 题库 > 学历提升 > 自学考试 > 自考本科 > 设计题

类Test33显示一个窗口,响应鼠标事件。 当鼠标逬入到窗口中时,在窗口最下面一 行,显示鼠标的当前坐标,如题33图所示。 

要求:编写代码,实现鼠标事件处理程序
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test33 implements
MouseMotionListener{
private JFrame frame;
private JLabel tf;
public static void main(Slring[] args)
{ Test33 two = new Test33();
two.go();
}
public void go()
{ frame = new JFrame("Mouse Control ");
Container contentPane = frame.getContentPaneO;
contentPane,add(new JLabel (" get mouse event"), BorderLayout.NORTH);
tf = new JLabelO;
contentPane. add(f, BorderLayout.SOUTH);
frame. addMouseMotionListener(this);
frame.setSize(300, 300);
frame.setVisible(true);
}

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

相关知识点试题

相关试卷