package test;
import java.awt.*;
import java.awt.event.*;
class ChessPad extends Panel implements MouseListener,ActionListener {
int x = -1, y = -1, chessColor = 1;
Button button = new Button("重新开局");
TextField text_1 = new TextField("请下黑子棋"),
text_2 = new TextField();
ChessPad() {
setSize(440,440);
setLayout(null); setBackground(Color.orange);
addMouseListener(this);
add(button); button.setBounds(10,5,60,26);
button.addActionListener(this);
add(text_1);
text_1.setBounds(90,5,90,24);
add(text_2);
text_2.setBounds(290,5,90,24);
text_1.setEditable(false);
text_2.setEditable(false);
}
public void paint(Graphics g) {
for(int i = 40; i <= 380;i = i+20) {
g.drawLine(40,i,400,i);
}
g.drawLine(40,400,400,400);
for(int j = 40; j <= 380; j = j+20 ) {
g.drawLine(j,40,j,400);
}
g.drawLine(400,40,400,400);
g.fillOval(97,97,6,6);
g.fillOval(337,97,6,6);
g.fillOval(97,337,6,6);
g.fillOval(337,337,6,6);
g.fillOval(217,217,6,6);
}
public void mousePressed(MouseEvent e) {
if(e.getModifiers()==InputEvent.BUTTON1_MASK) {
x = (int)e.getX();
y = (int)e.getY();
ChessPoint_black chesspoint_black = new ChessPoint_black(this);
ChessPoint_white chesspoint_white = new ChessPoint_white(this);
int a = (x+10)/20,
b = (y+10)/20;
if( x/20<2 || y/20<2 || x/20>19 || y/20>19) {}
else {
if(chessColor==1) {
this.add(chesspoint_black);
chesspoint_black.setBounds(a*20-10,b*20-10,20,20);
chessColor=chessColor*(-1);
text_2.setText("请白棋下子");
text_1.setText("");
}
else if(chessColor==-1) {
this.add(chesspoint_white);
chesspoint_white.setBounds(a*20-10,b*20-10,20,20);
chessColor = chessColor*(-1);
text_1.setText("请黑棋下子");
text_2.setText("");
}
}
}
}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {}
public void actionPerformed(ActionEvent e) {
this.removeAll(); chessColor = 1;
add(button); button.setBounds(10,5,60,26);
add(text_1); text_1.setBounds(90,5,90,24);
text_2.setText(""); text_1.setText("请黑棋下子");
add(text_2); text_2.setBounds(290,5,90,24);
}
}
class ChessPoint_black extends Canvas implements MouseListener {
ChessPad chesspad = null;
ChessPoint_black(ChessPad p) {
setSize(20,20); chesspad = p;
addMouseListener(this);
}
public void paint(Graphics g) {
g.setColor(Color.black);
g.fillOval(0,0,20,20);
}
public void mousePressed(MouseEvent e) {
if(e.getModifiers() == InputEvent.BUTTON3_MASK) {
chesspad.remove(this);
chesspad.chessColor=1;
chesspad.text_2.setText("");
chesspad.text_1.setText("请黑棋下子");
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
if(e.getClickCount()>=2) chesspad.remove(this);
}
}
class ChessPoint_white extends Canvas implements MouseListener {
ChessPad chesspad = null;
ChessPoint_white(ChessPad p) {
setSize(20,20);addMouseListener(this);
chesspad = p;
}
public void paint(Graphics g) {
g.setColor(Color.white);
g.fillOval(0,0,20,20);
}
public void mousePressed(MouseEvent e) {
if(e.getModifiers()==InputEvent.BUTTON3_MASK) {
chesspad.remove(this);
chesspad.chessColor=-1;
chesspad.text_2.setText("请白棋下子");
chesspad.text_1.setText("");
}
}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
if(e.getClickCount()>=2) chesspad.remove(this);
}
}
public class Chess extends Frame {
ChessPad chesspad = new ChessPad();
Chess() {
setVisible(true);
setLayout(null);
Label label = new Label("单击左键下棋子,双击吃棋子,用右键单击棋子悔棋",Label.CENTER);
add(label);
label.setBounds(70,55,440,26);
label.setBackground(Color.orange);
add(chesspad);
chesspad.setBounds(70,90,440,440);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
} );
pack(); setSize(600,550);
}
public static void main(String args[]) {
Chess chess = new Chess();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ssh框架新手学习项目
共158个文件
class:56个
java:42个
jsp:28个
4星 · 超过85%的资源 需积分: 10 162 下载量 60 浏览量
2011-07-12
13:58:17
上传
评论
收藏 192KB RAR 举报
温馨提示
都是从新手走过来的,理解新人的需求,给大家推荐一个比较适合学习的ssh项目。由于上传的大小原因,jar包,上传不了,晕死,对不起大家,这个供大家参考。不浪费大家的积分了。推荐大家下载网上书店的ssh框架项目。
资源推荐
资源详情
资源评论
收起资源包目录
ssh框架新手学习项目 (158个子文件)
UserDaoImpl.class 4KB
PaiXu.class 3KB
UserAction.class 3KB
ChessPad.class 3KB
FindUserAction.class 3KB
UploadAction.class 3KB
GotoPageAction.class 3KB
SendMailUtil.class 3KB
HibernateSessionFactory.class 2KB
UserServiceImpl.class 2KB
GetPasswordAction.class 2KB
UserPageBeanAction.class 2KB
ServerThread.class 2KB
DateMain.class 2KB
PX.class 2KB
SocketClient.class 2KB
NumberSplit.class 2KB
ChessPoint_white.class 2KB
ChessPoint_black.class 2KB
Equals.class 2KB
NumberSiShe.class 2KB
Upload.class 2KB
MonthDate.class 2KB
User.class 1KB
FindPage.class 1KB
PageBean.class 1KB
UserDaoImpl$1.class 1KB
SocketServer.class 1KB
Chess.class 1KB
MaxMin.class 1KB
demo.class 982B
DiGui.class 971B
SwitchCase.class 971B
Shuzu.class 931B
LeiXing.class 921B
maths.class 919B
FatherMian.class 917B
JiCheng.class 857B
JiCheng$1B.class 824B
C.class 817B
PaintovalFrame.class 809B
SendMailUtil$1.class 783B
WeiYi.class 776B
UserService.class 759B
UserDAO.class 747B
PaintovalFrame$1.class 665B
B.class 631B
JiCheng$1A.class 630B
Chess$1.class 616B
BaseAction.class 610B
PaintovalPane.class 609B
A.class 580B
Paintoval.class 508B
JiChengA.class 471B
JiChengB.class 471B
FatherClass.class 382B
.classpath 9KB
style.css 27KB
style1.css 4KB
treetext.css 3KB
appointment.gif 905B
CSS+TreeMenu.htm 4KB
Chess.java 4KB
GotoPageAction.java 3KB
HibernateSessionFactory.java 3KB
UserDaoImpl.java 3KB
FindUserAction.java 3KB
SendMailUtil.java 3KB
PaiXu.java 2KB
UserAction.java 2KB
UploadAction.java 2KB
DateMain.java 2KB
ServerThread.java 2KB
SocketClient.java 2KB
FindPage.java 1KB
NumberSplit.java 1KB
UserServiceImpl.java 1KB
GetPasswordAction.java 1KB
MonthDate.java 1KB
PX.java 1KB
Equals.java 1KB
UserPageBeanAction.java 1KB
Upload.java 1KB
demo.java 1KB
SocketServer.java 999B
NumberSiShe.java 984B
PageBean.java 960B
User.java 923B
SwitchCase.java 905B
Paintoval.java 838B
DiGui.java 814B
UserService.java 766B
UserDAO.java 751B
LeiXing.java 688B
maths.java 647B
WeiYi.java 628B
MaxMin.java 512B
FatherMian.java 492B
JiCheng.java 480B
Shuzu.java 447B
共 158 条
- 1
- 2
资源评论
- yjxqgd2013-07-29适合于新手,还是值得学习的
- 夜云爵2014-06-26没有JAR包,其他的都算可以,谢谢分享。
- LCT13257337272012-12-11这是一个相对教好的ssh,很不错,好好学习。
- haopengfei19852012-11-30我是新手,正好哪来学习。谢谢。
- dxdjj12252012-11-28这是一个相对教好的ssh
心醉白水
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功