java程序设计帮我分析一下每句话的意思好吗 30

importjava.awt.event.*;importjava.awt.*;importjavax.swing.*;publicclassHandleMoveexte... import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class HandleMove extends JPanel implements MouseListener,ActionListener {
Point [][] point;
int spendTime=0;
javax.swing.Timer recordTime;
JTextField showTime;
VerifySuccess verify;
HandleMove(){
recordTime=new javax.swing.Timer(1000,this);
showTime=new JTextField(16);
showTime.setEditable(false);
showTime.setHorizontalAlignment(JTextField.CENTER);
showTime.setFont(new Font("楷体_GB2312",Font.BOLD,16));
JLabel hitMess=new JLabel("用鼠标单击方块",JLabel.CENTER);
hitMess.setFont(new Font("楷体_GB2312",Font.BOLD,18));
add(hitMess);
add(showTime);
setBackground(Color.cyan);
}
public void setPoint(Point [][] p){
point=p;
}
public void initSpendTime(){
recordTime.stop();
spendTime=0;
showTime.setText(null);
}
public void setVerifySuccess(VerifySuccess verify){
this.verify=verify;
}
public void mousePressed(MouseEvent e){
recordTime.start();
Block block=null;
block=(Block)e.getSource();
int w=block.getBounds().width;
int h=block.getBounds().height;
int startI=-1,startJ=-1,endI=-1,endJ=-1;
Point startPoint=block.getAtPoint();
Point endPoint=null;
for(int i=0;i<point.length;i++){
for(int j=0;j<point[0].length;j++)
if(point[i][j].equals(startPoint)){
startI=i;
startJ=j;
break;
}
}
for(int i=0;i<point.length;i++){
for(int j=0;j<point[0].length;j++)
if(point[i][j].isHaveBlock()==false){
endI=i;
endJ=j;
endPoint=point[i][j];
break;
}
}
boolean moveCondition1=Math.abs(endI-startI)==1&&endJ==startJ;
boolean moveCondition2=Math.abs(endJ-startJ)==1&&endI==startI;
if(moveCondition1||moveCondition2){
block.setLocation(endPoint.getX(),endPoint.getY());
block.setAtPoint(endPoint);
endPoint.setBlock(block);
endPoint.setHaveBlock(true);
startPoint.setHaveBlock(false);
}
}
public void actionPerformed(ActionEvent e){
spendTime++;
showTime.setText("您的用时:"+spendTime+"秒");
}
public void mouseReleased(MouseEvent e){
if(verify.isSuccess()){
recordTime.stop();
JOptionPane.showMessageDialog(this,"您成功了!","消息框",
JOptionPane.INFORMATION_MESSAGE );
}
}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
}
展开
 我来答
cxl525
2011-07-08 · TA获得超过574个赞
知道答主
回答量:540
采纳率:0%
帮助的人:248万
展开全部
说一下大致的吧:
1.import引入包,下面会用到
2.public class HandleMove extends JPanel implements

MouseListener,ActionListener {
//创建HandleMove类并继承JPanel并实现MouseListener,ActionLister接口
2. Point [][] point;
int spendTime=0;
javax.swing.Timer recordTime;
JTextField showTime;
VerifySuccess verify;
//声明变量,各个类型地,这里的变量类型就是引入包import

javax.swing.*; 这里的
3.HandleMove(){
recordTime=new javax.swing.Timer(1000,this);
showTime=new JTextField(16);
showTime.setEditable(false);
showTime.setHorizontalAlignment(JTextField.CENTER);
showTime.setFont(new Font("楷体_GB2312",Font.BOLD,16)); //设

置字体
JLabel hitMess=new JLabel("用鼠标单击方块",JLabel.CENTER);//

设置JLabel标签
hitMess.setFont(new Font("楷体_GB2312",Font.BOLD,18)); //设置

字体
add(hitMess); //添加到Jpanel面板
add(showTime); //添加到Jpanel面板
setBackground(Color.cyan); //设置面板背景颜色
}
//定义构造器,并创建各个组件
4.下面就是创建各类方法
用于实现各个功能点
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式