public void jButton7_actionPerformed(ActionEvent e) {//打开存盘
if(jButton7.getText().equals(new String("打开存盘"))){
String opencontent[] = new String[2];
String filepath = new String();
String filename = new String();
if(IsStart==false){//打开存盘继续存盘游戏
int val;
do{
jFileChooser1.removeAll();
jFileChooser1 = new JFileChooser();
jFileChooser1.resetChoosableFileFilters();
jFileChooser1.setMultiSelectionEnabled(false);
jFileChooser1.setFileFilter(new MyFilter());
jFileChooser1.setAcceptAllFileFilterUsed(false);
jFileChooser1.setCurrentDirectory(new File("."));
val = jFileChooser1.showOpenDialog(this);
if(val!=JFileChooser.APPROVE_OPTION) break;
filename = jFileChooser1.getSelectedFile().getName();
filepath = jFileChooser1.getSelectedFile().getPath();
if(filename.length()<10||(!filename.substring(filename.length()-9,filename.length()).equals(new String(".huyidaoh"))))
filepath = filepath+".huyidaoh";
jFileChooser1.setSelectedFile(new File(filepath));
if(!jFileChooser1.getSelectedFile().exists()) JOptionPane.showConfirmDialog(null,filepath+" 存盘文件不存在\n请检查所给的文
件名称是否正确!","打开存盘文件",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
}
while(!jFileChooser1.getSelectedFile().exists()); ////文件不存在
if (val == JFileChooser.APPROVE_OPTION) {
try {
filename = jFileChooser1.getSelectedFile().getName();
filepath = jFileChooser1.getSelectedFile().getPath();
if(filename.length()<10||(!filename.substring(filename.length()-9,filename.length()).equals(new String(".huyidaoh"))))
filepath = filepath+".huyidaoh";
FileInputStream myfile = new FileInputStream(filepath);
byte buff[] = new byte[myfile.available()]; //创建和文件大小的数组
val = myfile.read(buff);
myfile.close();
opencontent = new String(buff).split("\n",2);
//先提取棋子坐标信息
for(int i=0;i<10;i++){
person[i].setP_positionX(new Integer(opencontent[0].substring(0+i*2,1+i*2)).intValue());
person[i].setP_positionY(new Integer(opencontent[0].substring(1+i*2,2+i*2)).intValue());
}
//再提取空闲地方信息
space1X = new Integer(opencontent[0].substring(20,21)).intValue();
space1Y = new Integer(opencontent[0].substring(21,22)).intValue();
space2X = new Integer(opencontent[0].substring(22,23)).intValue();
space2Y = new Integer(opencontent[0].substring(23,24)).intValue();
//再提取激活棋子ID
activenum = new Integer(opencontent[0].substring(24,25)).intValue();
//然后提取已走步子信息
movenum = new Integer(opencontent[0].substring(25,opencontent[0].length())).intValue();
//最后提取悔棋步子
huiqi = opencontent[1];
//提取信息完毕,下面初始化游戏
for(int i=0;i<10;i++) Move(i);
movenum = movenum-10;
jLabel1.setText("走了"+new Integer(movenum).toString()+"步");
IsStart = true;
jButton1.setEnabled(false);
jButton2.setEnabled(true);
jButton3.setEnabled(true);
jButton6.setEnabled(false);
jButton7.setEnabled(false);
jButton8.setEnabled(true);
jButton9.setEnabled(false);
}
catch (IOException ioe) {
JOptionPane.showConfirmDialog(null,"打开存盘文件失败!","打开存盘文件",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
}
}
}
}
else if(jButton7.getText().equals(new String("曹操移完"))) initMove("移动关羽",1,"guanyu.jpg","请移动关羽!");
else if(jButton7.getText().equals(new String("关羽移完"))) initMove("移动张飞",2,"zhangfei.jpg","请移动张飞!");
else if(jButton7.getText().equals(new String("张飞移完"))) initMove("移动赵云",3,"zhaoyun.jpg","请移动赵云!");
else if(jButton7.getText().equals(new String("赵云移完"))) initMove("移动黄忠",4,"huangzhong.jpg","请移动黄忠!");
else if(jButton7.getText().equals(new String("黄忠移完"))) initMove("移动马超",5,"machao.jpg","请移动马超!");
else if(jButton7.getText().equals(new String("马超移完"))) initMove("移动卒1",6,"zu.jpg","请移动卒1!");
else if(jButton7.getText().equals(new String("卒1移完"))) initMove("移动卒2",7,"zu.jpg","请移动卒2!");
else if(jButton7.getText().equals(new String("卒2移完"))) initMove("移动卒3",8,"zu.jpg","请移动卒3!");
else if(jButton7.getText().equals(new String("卒3移完"))) initMove("移动卒4",9,"zu.jpg","请移动卒4!");
else if(jButton7.getText().equals(new String("卒4移完"))){
//问是否保存棋局,倘若不保存下次不能用!
this.jLabel2.setVisible(false);
this.jLabel1.setText("全部移动完毕!");
jButton7.setText("打开存盘");
this.jButton1.setEnabled(true);
this.movenum = 0;
this.huiqi = "";
jButton6.setText("设置棋局");
String savecontent = new String();
String filepath = new String();
String filename = new String();
int huyidao[] =new int[20];
for(int i=0;i<20;i++){
huyidao[i] = 0;
}
//JOptionPane.showConfirmDialog(null,"123","打开存盘",
// JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
int huyidaohuyidao;
for(int i=0;i<10;i++){
for(huyidaohuyidao=0;huyidaohuyidao
1+huyidaohuyidao%person[i].getP_width()] = 1;
}
}
huyidaohuyidao = 0;
for(int i=0;i<20;i++){
if(huyidao[i]==0){
if(huyidaohuyidao==0) {
space1X = i%4+1;
space1Y = i/4+1;
huyidaohuyidao = huyidaohuyidao+1;
}
else if(huyidaohuyidao==1){
space2X = i%4+1;
space2Y = i/4+1;
break;
}
}
}
int val = JOptionPane.showConfirmDialog(null,"棋局设置完毕,是否保存棋局,以便下次可玩!","保存棋局",
JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);;
if(val==JFileChooser.APPROVE_OPTION){//点击是保存棋局
//保存棋盘棋子信息
for(int i=0;i<10;i++){
savecontent = savecontent+new Integer(person[i].getP_positionX()).toString()+new Integer(person[i].getP_positionY
()).toString();
}
//保存空闲地方信息
savecontent = savecontent+new Integer(space1X).toString()+new Integer(space1Y).toString()+new Integer(space2X).toString()+new
Integer(space2Y).toString();
do{
jFileChooser1.removeAll();
jFileChooser1 = new JFileChooser();
jFileChooser1.resetChoosableFileFilters();
jFileChooser1.setMultiSelectionEnabled(false);
jFileChooser1.setFileFilter(new MyFilter2());
jFileChooser1.setAcceptAllFileFilterUsed(false);
jFileChooser1.setCurrentDirectory(new File("."));
val = jFileChooser1.showSaveDialog(this);
if(val!=JFileChooser.APPROVE_OPTION) break;
filepath = jFileChooser1.getSelectedFile().getPath();
filename = jFileChooser1.getSelectedFile().getName();
if (filename.length() < 10 ||(!filename.substring(filename.length() - 9,filename.length()).equals(new String
(".huyidaos")))) filepath =filepath + ".huyidaos";
jFileChooser1.setSelectedFile(new File(filepath));
if(jFileChooser1.getSelectedFile().exists()){
int SaveFile_reply = JOptionPane.showConfirmDialog(null,
filepath + " 棋局文件已经存在\n想要替换它吗", "保存棋局文件",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (SaveFile_reply == JOptionPane.YES_OPTION) break;
}
}
while(jFileChooser1.getSelectedFile().exists()); //文件已经存在
if(val==JFileChooser.APPROVE_OPTION) {
filepath = jFileChooser1.getSelectedFile().getPath();
filename = jFileChooser1.getSelectedFile().getName();
try{
if(filename.length()<10||(!filename.substring(filename.length()-9,filename.length()).equals(new String
(".huyidaos")))) filepath = filepath+".huyidaos";
File file = new File(filepath);
FileWriter outText = new FileWriter(file);
outText.write(savecontent);
outText.close();
//先提取
}
catch(IOException ioe){
JOptionPane.showConfirmDialog(null,"保存棋局文件失败!","保存棋局文件",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
}
}
}
}
}
public void initMove(String a,int b,String c,String d){
this.jLabel2.setVisible(true);
jButton7.setText(a);
person[b].setP_positionX(5);
person[b].setP_positionY(5);
Icon ss = new ImageIcon(c);
jLabel2.setIcon(ss);
movenum = 0;
this.jLabel1.setText(d);
activenum = b;
}
public void jButton6_actionPerformed(ActionEvent e) {//设置棋局
if(jButton6.getText().equals(new String("设置棋局"))){
jButton1.setEnabled(false);
jButton6.setText("取消设置");
jButton7.setText("移动曹操");
guanyu.setVisible(false);
zhangfei.setVisible(false);
zhaoyun.setVisible(false);
huangzhong.setVisible(false);
machao.setVisible(false);
zu1.setVisible(false);
zu2.setVisible(false);
zu3.setVisible(false);
zu4.setVisible(false);
this.jLabel1.setText("请先移动曹操!");
activenum = -1;
//将原棋盘保存在huiqi变量中,便于取消设置时还原
huiqi = "";
for(int i=0;i<10;i++) huiqi = huiqi+new Integer(person[i].getP_positionX()).toString()+new Integer(person
[i].getP_positionY()).toString();
}
else{
activenum = -1;
this.jLabel2.setVisible(false);
jButton6.setText("设置棋局");
jButton7.setText("打开存盘");
jButton1.setEnabled(true);
guanyu.setVisible(true);
zhangfei.setVisible(true);
zhaoyun.setVisible(true);
huangzhong.setVisible(true);
machao.setVisible(true);
zu1.setVisible(true);
zu2.setVisible(true);
zu3.setVisible(true);
zu4.setVisible(true);
for(int i=0;i<10;i++){
person[i].setP_positionX(new Integer(huiqi.substring(0+2*i,1+2*i)).intValue());
person[i].setP_positionY(new Integer(huiqi.substring(1+2*i,2+2*i)).intValue());
Move(i);
}
huiqi = "";
movenum = 0;
this.jLabel1.setText("走了0步!");
}
}
public void caocao_mouseDragged(MouseEvent e) {//设置棋局时将曹操移到指定位置
dragDo("请先移动曹操!","caocao.jpg","caocao");
}
public void caocao_mouseReleased(MouseEvent e) {//拖动后释放
releaseDo("请先移动曹操!",0,"曹操移完",e.getX(),e.getY());
}
public void guanyu_mouseDragged(MouseEvent e) {//设置棋局时将关羽移到指定位置
dragDo("请移动关羽!","guanyu.jpg","guanyu");
}
public void dragDo(String a,String b,String c){
if(jButton6.getText().equals(new String("取消设置")) && this.jLabel1.getText().equals(a)){
Cursor cursor;//定义一个 Cursor
Image img = new ImageIcon(b).getImage();//一个图片
cursor = this.getToolkit().createCustomCursor(img, new Point(1,1), "c");
this.setCursor(cursor);
}
}
public void releaseDo(String a,int b,String c,int d,int e){
int tempx,tempy;
if(jButton6.getText().equals(new String("取消设置"))&& this.jLabel1.getText().equals(a)){
tempx = d+70*(person[b].getP_positionX()-1);
tempy = e+70*(person[b].getP_positionY()-1);
if(tempx+1>280-70*(person[b].getP_width()-1)||tempx<0||tempy<0||tempy+1>350-70*(person[b].getP_height()-1))
JOptionPane.showConfirmDialog(null,"请不要拖到棋盘外面","拖动棋子",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
else if(b==0&&(tempx/70+1)==2&&(tempy/70+1)==4) JOptionPane.showConfirmDialog(null,"曹操不能放在出口处!","拖动棋子",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
else{
tempx = tempx/70+1;
if(tempx>4) tempx = 4;
tempy = tempy/70+1;
if(tempy>5) tempy = 5;
person[b].setP_positionX(tempx);
person[b].setP_positionY(tempy);
if(activenum==1) guanyu.setVisible(true);
else if(activenum==2) zhangfei.setVisible(true);
else if(activenum==3) zhaoyun.setVisible(true);
else if(activenum==4) huangzhong.setVisible(true);
else if(activenum==5) machao.setVisible(true);
else if(activenum==6) zu1.setVisible(true);
else if(activenum==7) zu2.setVisible(true);
else if(activenum==8) zu3.setVisible(true);
else if(activenum==9) zu4.setVisible(true);
Move(b);
jButton7.setText(c);
}
this.setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) );
this.jLabel1.setText(a);
}
}
public void guanyu_mouseReleased(MouseEvent e) {//拖动后释放
releaseDo("请移动关羽!",1,"关羽移完",e.getX(),e.getY());
}
public void jLabel2_mouseDragged(MouseEvent e) {//移动图片
if(this.jLabel2.isVisible()) {
person[activenum].setP_positionX(5);
person[activenum].setP_positionY(5);
if(activenum==1) {
dragDo("请移动关羽!","guanyu.jpg","guanyu");
guanyu.setVisible(false);
}
else if(activenum==2) {
dragDo("请移动张飞!","zhangfei.jpg","zhangfei");
zhangfei.setVisible(false);
}
else if(activenum==3) {
dragDo("请移动赵云!","zhaoyun.jpg","zhaoyun");
zhaoyun.setVisible(false);
}
else if(activenum==4) {
dragDo("请移动黄忠!","huangzhong.jpg","huangzhong");
huangzhong.setVisible(false);
}
else if(activenum==5) {
dragDo("请移动马超!","machao.jpg","machao");
machao.setVisible(false);
}
else if(activenum==6) {
dragDo("请移动卒1!","zu.jpg","zu1");
zu1.setVisible(false);
}
else if(activenum==7) {
dragDo("请移动卒2!","zu.jpg","zu2");
zu2.setVisible(false);
}
else if(activenum==8) {
dragDo("请移动卒3!","zu.jpg","zu3");
zu3.setVisible(false);
}
else if(activenum==9) {
dragDo("请移动卒4!","zu.jpg","zu4");
zu4.setVisible(false);
}
}
}
public void jLabel2_mouseReleased(MouseEvent e) {
//JOptionPane.showConfirmDialog(null,new Integer((person[1].getP_positionX()*70+e.getX())/70).toString(),"打开存盘",
//JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
//先判断是否可以拖动,
person[activenum].setP_positionX(5);
person[activenum].setP_positionY(5);
if(IsDrag(activenum,e.getX(),e.getY())){
//拖动
if(activenum==1) releaseDo("请移动关羽!",activenum,"关羽移完",e.getX(),e.getY());
else if(activenum==2) releaseDo("请移动张飞!",activenum,"张飞移完",e.getX(),e.getY());
else if(activenum==3) releaseDo("请移动赵云!",activenum,"赵云移完",e.getX(),e.getY());
else if(activenum==4) releaseDo("请移动黄忠!",activenum,"黄忠移完",e.getX(),e.getY());
else if(activenum==5) releaseDo("请移动马超!",activenum,"马超移完",e.getX(),e.getY());
else if(activenum==6) releaseDo("请移动卒1!",activenum,"卒1移完",e.getX(),e.getY());
else if(activenum==7) releaseDo("请移动卒2!",activenum,"卒2移完",e.getX(),e.getY());
else if(activenum==8) releaseDo("请移动卒3!",activenum,"卒3移完",e.getX(),e.getY());
else if(activenum==9) releaseDo("请移动卒4!",activenum,"卒4移完",e.getX(),e.getY());
}
else{
JOptionPane.showConfirmDialog(null,"此位置已有棋子,请放置到别的地方!","拖动图片",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
this.setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) );
}
}
public boolean IsDrag(int n,int x,int y){//先判断是否可以拖动,
boolean theresult = true;
for(int i=0;i
(person[n].getP_positionY()*70+y)/70
theresult = false;
break;
}
}
return theresult;
}
public void jButton9_actionPerformed(ActionEvent e) {//打开棋局
String opencontent = new String();
String filepath = new String();
String filename = new String();
if(IsStart==false){//打开棋局玩棋局游戏
int val;
do{
jFileChooser1.removeAll();
jFileChooser1 = new JFileChooser();
jFileChooser1.resetChoosableFileFilters();
jFileChooser1.setMultiSelectionEnabled(false);
jFileChooser1.setFileFilter(new MyFilter2());
jFileChooser1.setAcceptAllFileFilterUsed(false);
jFileChooser1.setCurrentDirectory(new File("."));
val = jFileChooser1.showOpenDialog(this);
if(val!=JFileChooser.APPROVE_OPTION) break;
filename = jFileChooser1.getSelectedFile().getName();
filepath = jFileChooser1.getSelectedFile().getPath();
if(filename.length()<10||(!filename.substring(filename.length()-9,filename.length()).equals(new String(".huyidaos"))))
filepath = filepath+".huyidaos";
jFileChooser1.setSelectedFile(new File(filepath));
if(!jFileChooser1.getSelectedFile().exists()) JOptionPane.showConfirmDialog(null,filepath+" 棋局文件不存在\n请检查所给的文
件名称是否正确!","打开棋局文件",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
}
while(!jFileChooser1.getSelectedFile().exists()); ////文件不存在
if (val == JFileChooser.APPROVE_OPTION) {
try {
filename = jFileChooser1.getSelectedFile().getName();
filepath = jFileChooser1.getSelectedFile().getPath();
if(filename.length()<10||(!filename.substring(filename.length()-9,filename.length()).equals(new String(".huyidaos"))))
filepath = filepath+".huyidaos";
FileInputStream myfile = new FileInputStream(filepath);
byte buff[] = new byte[myfile.available()]; //创建和文件大小的数组
val = myfile.read(buff);
myfile.close();
opencontent = new String(buff);
//先提取棋子坐标信息
for(int i=0;i<10;i++){
person[i].setP_positionX(new Integer(opencontent.substring(0+i*2,1+i*2)).intValue());
person[i].setP_positionY(new Integer(opencontent.substring(1+i*2,2+i*2)).intValue());
}
//再提取空闲地方信息
space1X = new Integer(opencontent.substring(20,21)).intValue();
space1Y = new Integer(opencontent.substring(21,22)).intValue();
space2X = new Integer(opencontent.substring(22,23)).intValue();
space2Y = new Integer(opencontent.substring(23,24)).intValue();
activenum = -1;
movenum =0;
huiqi = "";
//提取信息完毕,下面初始化游戏
for(int i=0;i<10;i++) Move(i);
movenum = movenum-10;
jLabel1.setText("走了"+new Integer(movenum).toString()+"步");
IsStart = false;
jButton1.setEnabled(true);
jButton2.setEnabled(false);
jButton3.setEnabled(false);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(false);
jButton9.setEnabled(true);
}
catch (IOException ioe) {
JOptionPane.showConfirmDialog(null,"打开棋局文件失败!","打开棋局文件",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE);
}
}
}
}
public void jButton11_actionPerformed(ActionEvent e) {//点击关于本软件
JOptionPane.showConfirmDialog(null,"\n华容道1.0版\n作者:胡一刀\n联系方式:北师大计算机02级\nQQ:147017669
Email:hlq83@126.com\n\n\n注:本程序为作者学习Java时期末试题所编,其中可能有不少bug或改进的地方,欢迎大家指正。\n作者也将在今
后不断推出新版本,敬请大家关注。\n本软件可免费用于学习和研究,欢迎与作者交流。\n倘若要商用,请与本人联系,否则触犯到作者版权,
本人必究。","软件说明",
JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
}
public void jButton10_actionPerformed(ActionEvent e) {//点击游戏规则
JOptionPane.showConfirmDialog(null,"\n1.点击开始游戏开始一盘游戏!曹操移到最下方正中处游戏胜利!\n2.棋子移动:点击一下棋
子,再点击空白处,只要可以到达,棋子就会移到空白处!\n3.可以任意n步悔棋,直至游戏开始点。便于高手研究每局最小步数!\n4.点击重
新开始,重新开始新的游戏。\n5.开始任意设置棋局,倘若你要以后还想玩此棋局,请保存棋局。先将曹操移动到你\n要设置的位置,然后点
击曹操移完开始移动关羽,依此类推设置好所有棋子。\n6.游戏可以存盘,下次打开存盘接着玩,还可以导入棋局玩你想玩的棋局,请不要随
\n意跟改存盘文件和棋局文件,否则打开会发生不可预告的错误!\n7.可以开启和关闭背景音乐以及棋子走步声!默认背景音乐关闭,棋子走
步声开启!\n8.最后一点希望大家尽情享受本游戏的快乐,有什么好的建议,请与作者联系!\n9.作者:胡一刀 hlq83@126.com","规则介绍",
JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
}
public void jButton12_actionPerformed(ActionEvent e){//开启或关闭背景音乐
if(jButton12.getText().equals(new String("开启背景音乐"))){
jButton12.setText("关闭背景音乐");
//开始播放背景音乐
try{
File myMidiFile = new File("bg.mid");
ser = MidiSystem.getSequencer();
ser.addMetaEventListener(
new MetaEventListener() {
public void meta(MetaMessage event) {
if (event.getType() == 47) {//播放完毕,继续播放
if(ser != null && ser.isOpen()){
ser.start();
}
}
}
});
Sequence mySeq = MidiSystem.getSequence(myMidiFile);
ser.open();
ser.setSequence(mySeq);
ser.start();
if(ser instanceof Synthesizer){
Synthesizer sy = (Synthesizer)ser;
MidiChannel channels[] = sy.getChannels();
for (int i = 0; i < channels.length; i++){
channels[i].controlChange(7,(int)((178 / 100.0) * 127.0)& 0xff);
}
}
}
catch(javax.sound.midi.InvalidMidiDataException e2){
}
catch(javax.sound.midi.MidiUnavailableException e3){
}
catch(IOException e4){
}
}
else{
jButton12.setText("开启背景音乐");
if(ser != null && ser.isOpen()) ser.stop();
}
}
}
class huangrongdao_jButton12_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton12_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton12_actionPerformed(e);
}
}
class huangrongdao_jButton5_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton5_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}
class huangrongdao_jButton10_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton10_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton10_actionPerformed(e);
}
}
class huangrongdao_jButton11_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton11_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton11_actionPerformed(e);
}
}
class huangrongdao_jButton9_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton9_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton9_actionPerformed(e);
}
}
class huangrongdao_jLabel2_mouseAdapter
extends MouseAdapter {
private huangrongdao adaptee;
huangrongdao_jLabel2_mouseAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseReleased(MouseEvent e) {
adaptee.jLabel2_mouseReleased(e);
}
}
class huangrongdao_jLabel2_mouseMotionAdapter
extends MouseMotionAdapter {
private huangrongdao adaptee;
huangrongdao_jLabel2_mouseMotionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseDragged(MouseEvent e) {
adaptee.jLabel2_mouseDragged(e);
}
}
class huangrongdao_jButton6_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton6_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton6_actionPerformed(e);
}
}
class huangrongdao_jButton7_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton7_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton7_actionPerformed(e);
}
}
class huangrongdao_jButton8_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton8_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton8_actionPerformed(e);
}
}
class huangrongdao_jPanel1_mouseAdapter
extends MouseAdapter {
private huangrongdao adaptee;
huangrongdao_jPanel1_mouseAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jPanel1_mouseClicked(e);
}
}
class huangrongdao_zu4_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_zu4_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.zu4_actionPerformed(e);
}
}
class huangrongdao_zu3_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_zu3_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.zu3_actionPerformed(e);
}
}
class huangrongdao_zu2_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_zu2_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.zu2_actionPerformed(e);
}
}
class huangrongdao_zu1_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_zu1_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.zu1_actionPerformed(e);
}
}
class huangrongdao_machao_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_machao_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.machao_actionPerformed(e);
}
}
class huangrongdao_huangzhong_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_huangzhong_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.huangzhong_actionPerformed(e);
}
}
class huangrongdao_zhaoyun_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_zhaoyun_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.zhaoyun_actionPerformed(e);
}
}
class huangrongdao_guanyu_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_guanyu_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.guanyu_actionPerformed(e);
}
}
class huangrongdao_guanyu_mouseAdapter
extends MouseAdapter {
private huangrongdao adaptee;
huangrongdao_guanyu_mouseAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseReleased(MouseEvent e) {
adaptee.guanyu_mouseReleased(e);
}
}
class huangrongdao_guanyu_mouseMotionAdapter
extends MouseMotionAdapter {
private huangrongdao adaptee;
huangrongdao_guanyu_mouseMotionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseDragged(MouseEvent e) {
adaptee.guanyu_mouseDragged(e);
}
}
class huangrongdao_caocao_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_caocao_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.caocao_actionPerformed(e);
}
}
class huangrongdao_caocao_mouseMotionAdapter
extends MouseMotionAdapter {
private huangrongdao adaptee;
huangrongdao_caocao_mouseMotionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseDragged(MouseEvent e) {
adaptee.caocao_mouseDragged(e);
}
}
class huangrongdao_caocao_mouseAdapter
extends MouseAdapter {
private huangrongdao adaptee;
huangrongdao_caocao_mouseAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void mouseReleased(MouseEvent e) {
adaptee.caocao_mouseReleased(e);
}
}
class huangrongdao_jButton4_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton4_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton4_actionPerformed(e);
}
}
class huangrongdao_jButton1_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton1_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class huangrongdao_jButton2_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton2_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class huangrongdao_jButton3_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_jButton3_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
class huangrongdao_this_windowAdapter
extends WindowAdapter {
private huangrongdao adaptee;
huangrongdao_this_windowAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void windowClosing(WindowEvent e) {
adaptee.this_windowClosing(e);
}
}
class huangrongdao_zhangfei_actionAdapter
implements ActionListener {
private huangrongdao adaptee;
huangrongdao_zhangfei_actionAdapter(huangrongdao adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.zhangfei_actionPerformed(e);
}
}
//建了一个类MyFilter,过滤为存盘文件
class MyFilter extends javax.swing.filechooser.FileFilter {
public static String getExtension(File f) {
String ext = null;
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
}
return ext;
}
public boolean accept(File file){
if (file.isDirectory()) {
return true;
}
String extension = getExtension(file);
if (extension != null) {
if (extension.equals("huyidaoh"))
return true;
else
return false;
}
return false;
}
public String getDescription(){
return "*.huyidaoh";
}
}
//建了一个类MyFilter2,过滤为棋局文件
class MyFilter2 extends javax.swing.filechooser.FileFilter {
public static String getExtension(File f) {
String ext = null;
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
}
return ext;
}
public boolean accept(File file){
if (file.isDirectory()) {
return true;
}
String extension = getExtension(file);
if (extension != null) {
if (extension.equals("huyidaos"))
return true;
else
return false;
}
return false;
}
public String getDescription(){
return "*.huyidaos";
}
}
class SoundMove implements FilenameFilter, ActionListener //走棋声音类
{
File theFile=null;
AudioData theData=null;
InputStream nowPlaying=null;
public SoundMove()
{
try{
theFile=new File("move.wav");
if(theFile!=null){
FileInputStream fis=new FileInputStream(theFile);
AudioStream as=new AudioStream(fis);
theData=as.getData();
}
else{
System.out.println("空");
}
}
catch(IOException e){
System.err.println(e);
}
AudioDataStream ads=new AudioDataStream(theData);
AudioPlayer.player.start(ads);
nowPlaying=ads;
}
public boolean accept(File dir, String name) {
return true;
}
public void actionPerformed(ActionEvent e) {
// TODO: Add your code here
}
}
person.java 共98行
//Note: 本程序代码无版权限制,仅用于研究,但因为使用不当等原因 _
// 对你或社会造成伤害,作者概不负责。
// ╭═══════════════════╮
// ║ 〖胡一刀 〗 ║
// ║ ║
// ║ ----------------------------- ║
// ┤ CodeName:person.java ├
// ║ FirstBuind:2005-6-4 ║
// ║ Copyright:Freeware ║
// ║ Email:hlq83@126.com ║
// ╰═══════════════════╯
//Last Modify:2005-6-4
package huanrongdao;
/**
*
Title: 华容道
Description: 期末作业
Copyright: Copyright (c) 2005
Company: bnu
public void setP_name(String p_name) {
this.p_name = p_name;
}
public void setP_width(int p_width) {
this.p_width = p_width;
}
public void setP_height(int p_height) {
this.p_height = p_height;
}
public void setP_positionX(int p_positionX) {
this.p_positionX = p_positionX;
}
public void setP_positionY(int p_positionY) {
this.p_positionY = p_positionY;
}
public void setP_active(boolean p_active) {
this.p_active = p_active;
}
public String getP_name() {
return p_name;
}
public int getP_width() {
return p_width;
}
public int getP_height() {
return p_height;
}
public int getP_positionX() {
return p_positionX;
}
public int getP_positionY() {
return p_positionY;
}
public boolean isP_active() {
return p_active;
}
private String p_name;//名字
private int p_width;//所占宽度,如曹操为2卒为1
private int p_height;//所占高度如曹操为2卒为1
private int p_positionX;//左上角所在位置的横坐标,如开始时曹操在1处
private int p_positionY;//左上角所在位置的纵坐标,如开始时曹操在1处
private boolean p_active;//为true时表示当前为所要走动的棋子,后来发现没有用到,暂时保留在这。
private void jbInit() throws Exception {
}
}
你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=1883972