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

上传资料

关闭

关闭

关闭

封号提示

内容

首页 java围棋小游戏代码

java围棋小游戏代码.doc

java围棋小游戏代码

李俭德
2017-09-01 0人阅读 举报 0 0 暂无简介

简介:本文档为《java围棋小游戏代码doc》,可适用于职业岗位领域

java围棋小游戏代码importjavaawt*importjavaawtevent*classChessPadextendsPanelimplementsMouseListener,ActionListener{intx=,y=,Æå×ÓÑÕÉ=ØÖÆÆå×ÓÑÕɵÄÉÔäÁButtonbutton=newButton("ÖØЪÖ")ØÖÆÖØЪֵÄÅTextFieldtext=newTextField("ÇëºÚÆåÏÂ×Ó"),text=newTextField("")ÌáÊÏÂÆåµÄÁöÎÄòChessPad(){setSize(,)setLayout()setBackground(Colorpink)addMouseListener(this)add(button)buttonsetBounds(,,,)buttonaddActionListener(this)add(text)textsetBounds(,,,)add(text)textsetBounds(,,,)textsetEditable(false)textsetEditable(false)}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(,,,)}publicvoidmousePressed(MouseEvente)µÏÂÊóê×óüÊÏÂÆå×Ó{if(egetModifiers()==InputEventBUTTONMASK){x=(int)egetX()y=(int)egetY()ñÈÏÂÊóêʵÄ×øêÎÖÃChessPointblackchesspointblack=newChessPointblack(this)ChessPointwhitechesspointwhite=newChessPointwhite(this)inta=(x),b=(y)if(x<||y<||x>||y>)ÆåÅÌÍâÏÂ×Ó{}else{if(Æå×ÓÑÕÉ==)µÆå×ÓÑÕÉÊÇÊϺÚÆå×Ó{thisadd(chesspointblack)chesspointblacksetBounds(a*,b*,,)Æå×ÓÑÕÉ=Æå×ÓÑÕÉ*()textsetText("Çë×ÆåÏÂ×Ó")textsetText("")}elseif(Æå×ÓÑÕÉ==)µÆå×ÓÑÕÉÊÇÊÏÂ×Æå×Ó{thisadd(chesspointwhite)chesspointwhitesetBounds(a*,b*,,)Æå×ÓÑÕÉ=Æå×ÓÑÕÉ*()textsetText("ÇëºÚÆåÏÂ×Ó")textsetText("")}}}}publicvoidmouseReleased(MouseEvente){}publicvoidmouseEntered(MouseEvente){}publicvoidmouseExited(MouseEvente){}publicvoidmouseClicked(MouseEvente){}publicvoidactionPerformed(ActionEvente){thisremoveAll()Æå×ÓÑÕÉ=add(button)buttonsetBounds(,,,)add(text)textsetBounds(,,,)textsetText("")textsetText("ÇëºÚÆå×ÓÏÂ×Ó")add(text)textsetBounds(,,,)}}ºÔðºÚÉÆå×ÓµÄÀàclassChessPointblackextendsCanvasimplementsMouseListener{ChessPadchesspad=ChessPointblack(ChessPadp){setSize(,)chesspad=paddMouseListener(this)}publicvoidpaint(Graphicsg){gsetColor(Colorblack)gfillOval(,,,)}{if(egetModifiers()==InputEventBUTTONMASK){chesspadremove(this)µÓÃÊóêÓÒÆå×ÓÊÓÆåÅÌÖÐȵôÆå×ÓÚÆåchesspadÆå×ÓÑÕÉ=chesspadtextsetText("")chesspadtextsetText("ÇëºÚÆå×ÓÏÂ×Ó")}}publicvoidmouseReleased(MouseEvente){}publicvoidmouseEntered(MouseEvente){}publicvoidmouseExited(MouseEvente){}publicvoidmouseClicked(MouseEvente){if(egetClickCount()>=)chesspadremove(this)µËÃÆå×ÓÊÔµôÃÆå×Ó}}ºÔð×ÉÆå×ÓµÄÀàclassChessPointwhiteextendsCanvasimplementsMouseListener{ChessPadchesspad=ChessPointwhite(ChessPadp){setSize(,)addMouseListener(this)chesspad=p}publicvoidpaint(Graphicsg){gsetColor(Colorwhite)gfillOval(,,,)}publicvoidmousePressed(MouseEvente){if(egetModifiers()==InputEventBUTTONMASK){chesspadremove(this)chesspadÆå×ÓÑÕÉ=chesspadtextsetText("Çë×ÆåÏÂ×Ó")chesspadtextsetText("")}}publicvoidmouseReleased(MouseEvente){}publicvoidmouseEntered(MouseEvente){}publicvoidmouseExited(MouseEvente){}publicvoidmouseClicked(MouseEvente){if(egetClickCount()>=)chesspadremove(this)}}publicclassChessextendsFrameÌíÓÆåÅÌÚ{ChessPadchesspad=newChessPad()Chess(){setSize(,)setVisible(true)setLayout()Labellabel=newLabel("µÏÂÆå×ÓËÔÆå×ÓÓÒÆå×ÓÚÆå",LabelCENTER)add(label)labelsetBounds(,,,)labelsetBackground(Colororange)add(chesspad)chesspadsetBounds(,,,)addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){Systemexit()}})}publicstaticvoidmain(Stringargs){Chesschess=newChess()}}

用户评价(0)

关闭

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

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

提示

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

文档小程序码

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

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/7

java围棋小游戏代码

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利