in = new ImageIcon("士1.GIF");
for (i=12,k=155;i<14;i++,k+=95)
{
play[i] = new JLabel(in);
play[i].setBounds(k,10,40,40);
play[i].setName("士1");
}
//卒
in = new ImageIcon("卒1.GIF");
for (i=16,k=10;i<21;i++,k+=96.5)
{
play[i] = new JLabel(in);
play[i].setBounds(k,160,40,40);
play[i].setName("卒1" + i);
}
//炮
in = new ImageIcon("炮1.GIF");
for (i=26,k=60;i<28;i++,k+=289)
{
play[i] = new JLabel(in);
play[i].setBounds(k,110,40,40);
play[i].setName("炮1" + i);
}
//将
in = new ImageIcon("将1.GIF");
play[30] = new JLabel(in);
play[30].setBounds(205,10,40,40);
play[30].setName("将1");
//红色棋子
//车
in = new ImageIcon("车2.GIF");
for (i=2,k=10;i<4;i++,k+=385)
{
play[i] = new JLabel(in);
play[i].setBounds(k,450,40,40);
play[i].setName("车2");
}
//马
in = new ImageIcon("马2.GIF");
for (i=6,k=60;i<8;i++,k+=285)
{
play[i] = new JLabel(in);
play[i].setBounds(k,450,40,40);
play[i].setName("马2");
}
//相
in = new ImageIcon("相2.GIF");
for (i=10,k=105;i<12;i++,k+=195)
{
play[i] = new JLabel(in);
play[i].setBounds(k,450,40,40);
play[i].setName("相2");
}
//士
in = new ImageIcon("士2.GIF");
for (i=14,k=155;i<16;i++,k+=95)
{
play[i] = new JLabel(in);
play[i].setBounds(k,450,40,40);
play[i].setName("士2");
}
//兵
in = new ImageIcon("兵2.GIF");
for (i=21,k=10;i<26;i++,k+=96.5)
{
play[i] = new JLabel(in);
play[i].setBounds(k,300,40,40);
play[i].setName("兵2" + i);
}
//炮
in = new ImageIcon("炮2.GIF");
for (i=28,k=60;i<30;i++,k+=289)
{
play[i] = new JLabel(in);
play[i].setBounds(k,350,40,40);
play[i].setName("炮2" + i);
}
//帅
in = new ImageIcon("帅2.GIF");
play[31] = new JLabel(in);
play[31].setBounds(205,450,40,40);
play[31].setName("帅2");
}
/*线程方法控制棋子闪烁*/
public void run()
{
while (true)
{
//单击棋子第一下开始闪烁
if (chessManClick)
{
play[Man].setVisible(false);
//时间控制
try
{
tmain.sleep(500);
}
catch(Exception e){}
play[Man].setVisible(true);
}
//闪烁当前提示信息 以免用户看不见
else
{
text.setVisible(false);
//时间控制
try
{
tmain.sleep(500);
}
catch(Exception e){}
text.setVisible(true);
}
try
{
tmain.sleep(500);
}
catch (Exception e){}
}
}
/*单击棋子方法************************/
public void mouseClicked(MouseEvent me)
{
MusicDemo1 t = new MusicDemo1();
//当前坐标
int Ex=0,Ey=0;
//启动线程
if (tmain == null)