下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 围棋源代码-Java_Applet小程序

围棋源代码-Java_Applet小程序.doc

围棋源代码-Java_Applet小程序

叶帆影
2018-10-03 0人阅读 举报 0 0 暂无简介

简介:本文档为《围棋源代码-Java_Applet小程序doc》,可适用于战略管理领域

围棋源代码JavaApplet小程序核准通过归档资料。未经允许请勿外传~心浪微博:朴恩俊丶熊猫核准通过归档资料。未经允许请勿外传~核准通过归档资料。未经允许请勿外传~*一个Java围棋程序源代码*importjavaawt*importjavaawtevent*importjavaxswingJOptionPanepublicclassChessextendsFrame{ChessPadchesspad=newChessPad()Chess(){add(chesspad)chesspadsetBounds(,,,)Labellabel=newLabel("clicktopoint,doubledclicktoremove,rightclicktoback",LabelCENTER)add(label)labelsetBounds(,,,)labelsetBackground(Colororange)addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){Systemexit()}})setLayout()setVisible(true)setSize(,)}publicstaticvoidmain(Stringargs){Chesschess=newChess()}}classChessPadextendsPanelimplementsMouseListener,ActionListener,FocusListener{intx=,y=,chessColor=Stringblackname="",whitename=""Buttonstartbutton=newButton("restart")ButtoninputButton=newButton("input")TextFieldtext=newTextField("blackplease"),text=newTextField(""),whitepleasetext=newTextField("black'name"),text=newTextField("white'name")ChessPad(){add(inputButton)inputButtonsetBounds(,,,)inputButtonaddActionListener(this)inputButtonaddFocusListener(this)add(text)textsetBounds(,,,)textaddFocusListener(this)textsetEditable(true)add(text)textsetBounds(,,,)textaddFocusListener(this)textsetEditable(true)add(startbutton)startbuttonsetBounds(,,,)startbuttonsetEnabled(false)startbuttonaddActionListener(this)add(text)textsetBounds(,,,)textsetEnabled(false)textsetEditable(false)add(text)textsetBounds(,,,)textsetEnabled(false)textsetEditable(false)setSize(,)setLayout()setBackground(Colororange)addMouseListener(this)}publicvoidpaint(Graphicsg){for(inti=i<=i=i){gdrawLine(,i,,i)}gdrawLine(,,,)for(intj=j<=j=j){gdrawLine(j,,j,)}gdrawLine(,,,)gfillOval(,,,)gfillOval(,,,)gfillOval(,,,)gfillOval(,,,)gfillOval(,,,)}publicvoidfocusGained(FocusEvente){Componentcom=(Component)egetSource()if(com==text){textsetText("")}elseif(com==text){textsetText("")}}publicvoidfocusLost(FocusEvente){}publicvoidmousePressed(MouseEvente){if(egetModifiers()==InputEventBUTTONMASK){x=(int)egetX()y=(int)egetY()inta=(x),b=(y)ChessPointblackchesspointblack=newChessPointblack(this)ChessPointwhitechesspointwhite=newChessPointwhite(this)if(x<||y<||x>||y>){}else{if(blacknamelength()==||whitenamelength()==){JOptionPaneshowMessageDialog(this,"pleaseinputtheplayer'sname,andclickinputbuttonbeforeyoustartchess!","reminder",JOptionPaneWARNINGMESSAGE)}elseif(blacknameequals("black'name")){JOptionPaneshowMessageDialog(this,"pleaseinputtheblackplayer'sname,andclickinputbutton","reminder",JOptionPaneWARNINGMESSAGE)}elseif(whitenameequals("white'name")){JOptionPaneshowMessageDialog(this,"pleaseinputthewhiteplayer'sname,andclickinputbutton","reminder",JOptionPaneWARNINGMESSAGE)}else{if(chessColor==){thisadd(chesspointblack)chesspointblacksetBounds(a*,b*,,)chessColor=chessColor*()textsetText(thiswhitename"please")textsetText("")}elseif(chessColor==){thisadd(chesspointwhite)chesspointwhitesetBounds(a*,b*,,)chessColor=chessColor*()textsetText(thisblackname"please")textsetText("")}}}}}publicvoidmouseReleased(MouseEvente){}publicvoidmouseEntered(MouseEvente){}publicvoidmouseExited(MouseEvente){}publicvoidmouseClicked(MouseEvente){}publicvoidactionPerformed(ActionEvente){if(egetSource()==inputButton){blackname=textgetText()trim()whitename=textgetText()trim()if(blacknamelength()==||whitenamelength()==){JOptionPaneshowMessageDialog(this,"youdidnotcompletetheinformationoryouhaveinputtheillegalcharacteristics!","reminder",JOptionPaneWARNINGMESSAGE)}elseif(blacknameequals("black'name")){JOptionPaneshowMessageDialog(this,"pleaseinputtheblackplayer'sname","reminder",JOptionPaneWARNINGMESSAGE)}elseif(whitenameequals("white'name")){JOptionPaneshowMessageDialog(this,"pleaseinputthewhiteplayer'sname","reminder",JOptionPaneWARNINGMESSAGE)}elseif(textgetText()equals(textgetText())){JOptionPaneshowMessageDialog(this,"youhaveinputthesamenamefortwodifferentplayers,pleasereinputtheplayersname","reminder",JOptionPaneWARNINGMESSAGE)}else{inputButtonsetEnabled(false)textremoveFocusListener(this)textsetEnabled(false)textsetEnabled(false)startbuttonsetEnabled(true)textsetEnabled(true)textsetText(blackname"please")textsetEnabled(true)}}elseif(egetSource()==startbutton){thisremoveAll()inputButtonsetEnabled(true)textsetEnabled(true)textsetEnabled(true)startbuttonsetEnabled(false)textsetEnabled(false)textsetEnabled(false)chessColor=add(startbutton)startbuttonsetBounds(,,,)add(text)textsetBounds(,,,)textsetText("blackplease")add(text)textsetBounds(,,,)textsetText("")add(inputButton)inputButtonsetBounds(,,,)add(text)textsetText("black'name")textaddFocusListener(this)textsetBounds(,,,)add(text)textsetText("white'name")textsetBounds(,,,)blackname=""whitename=""}}}classChessPointblackextendsCanvasimplementsMouseListener{ChessPadchesspad=ChessPointblack(ChessPadp){setSize(,)chesspad=paddMouseListener(this)}publicvoidpaint(Graphicsg){gsetColor(Colorblack)gfillOval(,,,)}publicvoidmousePressed(MouseEvente){if(egetModifiers()==InputEventBUTTONMASK){chesspadremove(this)chesspadchessColor=chesspadtextsetText("")chesspadtextsetText(chesspadblackname"please")}}publicvoidmouseReleased(MouseEvente){}publicvoidmouseEntered(MouseEvente){}publicvoidmouseExited(MouseEvente){}publicvoidmouseClicked(MouseEvente){if(egetClickCount()>=){chesspadremove(this)}}}classChessPointwhiteextendsCanvasimplementsMouseListener{ChessPadchesspad=ChessPointwhite(ChessPadp){setSize(,)chesspad=paddMouseListener(this)}publicvoidpaint(Graphicsg){gsetColor(Colorwhite)gfillOval(,,,)}publicvoidmousePressed(MouseEvente){if(egetModifiers()==InputEventBUTTONMASK){chesspadremove(this)chesspadchessColor=chesspadtextsetText("")chesspadtextsetText(chesspadwhitename"please")}}publicvoidmouseReleased(MouseEvente){}publicvoidmouseEntered(MouseEvente){}publicvoidmouseExited(MouseEvente){}publicvoidmouseClicked(MouseEvente){if(egetClickCount()>=){chesspadremove(this)}}}

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/15

围棋源代码-Java_Applet小程序

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利