请详细的帮我解释下这个java程序!

来源:百度知道 编辑:UC知道 时间:2024/05/14 05:32:40
import java.awt.*;
import java.awt.event.*;
public class HJ extends Frame implements MouseMotionListener
{

static HJ frm=new HJ();
static WinLis wlis=new WinLis();
public HJ()
{

}
public static void main(String args[])
{
frm.setBackground(Color.orange);
frm.setLayout(null);
frm.addMouseMotionListener(frm);//添加鼠标事件
frm.setSize(200, 150);//设置初始大小
frm.addWindowListener(wlis);//添加窗体事件
frm.setVisible(true);
}
public void mouseMoved(MouseEvent e)
{
frm.setTitle("x="+e.getX()+"y="+e.getY());

}

static class WinLis extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
frm.dispose();//当按下关闭按纽的时候关闭窗体
}
}
}
各位大虾,谢谢了,我下午要呢!

import java.awt.*;
import java.awt.event.*;

public class HJ extends Frame implements MouseMotionListener {

private static final long serialVersionUID = 1L;

static HJ frm = new HJ();

static WinLis wlis = new WinLis();

public HJ() {//构造函数

}

public static void main(String args[]) {
frm.setBackground(Color.orange);//设置背景色为橙色
frm.setLayout(null);//这句话没用
frm.addMouseMotionListener(frm);// 添加鼠标事件
frm.setSize(200, 150);// 设置初始大小
frm.addWindowListener(wlis);// 添加窗体事件
frm.setVisible(true);//窗体可见
}

public void mouseMoved(MouseEvent e) {
frm.setTitle("x=" + e.getX() + "y=" + e.getY()); //设置标题

}

static class WinLis extends WindowAdapter {
public void windowClosing(WindowEvent e) {
frm.dispose();// 当按下关闭按纽的时候关闭窗体
}
}

public void mouseDragged(MouseEvent e) {