总共七个类
package com;
import jint;
import jav.evenseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
public class Card extends JLabel implements MouseListener{
Main main;//Main类的引用
String name;//图片url名字
boolean up;//是否正反面
boolean canClick=false;//是否可被点击
boolean clicked=false;//是否点击过
public Card(Main m,String name,boolean up){
this.main=m;
this.name=name;
tp=up;
if(tp)
turnFront();
else {
thinRear();
}
this.setSize(71, 96);
tetVisible(true);
tddMouseListener(this);
}
//正面
public void turnFront() {
this.setIcon(new ImageIcon("images/" + name + ".gif"));
tp = true;
}
//反面
public void turnRear() {
thiIcon(new ImageIcon("images/rea"));
thi = false;
}
***@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
if(canClick)
{
Point from=this.getLocation();
int step; //移动的距离
if(clicked)
step=-20;
else {
step=20;
}
clicked=!clicked; //反向
//当被选中的时候,向前移动一步/后退一步
Comove(this,from,new Point(f,from.y-step));
}
}
public void mouseEntered(MouseEvent arg0) {}
public void mouseExited(MouseEvent arg0) {}
public void mousePressed(MouseEvent arg0) {}
public void mouseReleased(MouseEvent arg0) {}
}
package com;
public enum CardType {
c1,//单牌。
c2,//对子。
c3,//3不带。
c4,//炸弹。
c31,//3带1。
c32,//3带2。
c411,//4带2个单,或者一对
c422,//4带2对
c123,//连子。
c1122,//连队。
c111222,//飞机。
c11122234,//飞机带单排.
c1112223344,//飞机带对子.
c0//不能出牌
}
package com;
import jant;
import java.
java项目实例源代码斗地主 来自淘豆网m.daumloan.com转载请标明出处.