这是我设计的一个围棋游戏界面,(功能还没有实现),编译过了,但是怎么也不能运行,请各位帮一下忙,修改一下
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import sun.audio.*;
import java.util.*;
public class WeiQi extends JFrame
{
public static void main(String args[])
{
WeiQi screen=new WeiQi();
}
public WeiQi()
{
qipan pan1;
jishi pan2;
pan1=new qipan();
pan2=new jishi();
Container con=getContentPane();
con.add(pan1,BorderLayout.CENTER);
con.add(pan2,BorderLayout.EAST);
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent e)
{System.exit(0);}
});
setSize(500,600);
setVisible(true);
}
}
class qipan extends JPanel implements MouseListener
{
Graphics write=getGraphics();
int dx=5,dy=5,x=0,y=0;
boolean flag=true;
public qipan()
{
setBackground(Color.yellow);
this.addMouseListener(this);
}
public void pain(Graphics g)
{
write.setColor(Color.black);
for(int i=0;i<19;i++)
{ write.drawLine(dx,y+dy,19*dx,y+dy);
y=y+5;
}
for(int j=0;j<19;j++)
{ write.drawLine(x+dx,dy,x+dx,19*dx);
x=x+5;
}
}
public void update(Graphics g)
{
pain(g);
}
public void mousePressed(MouseEvent e)
{ int xl,yl;
xl=e.getX();
yl=e.getY();
if(flag){write.setColor(Color.black); flag=false;}
else {write.setColor(Color.white); flag=true;}
if(xl%5==0&yl%5==0) write.fillOval(xl,yl,2,2);
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
}
class jishi extends JPanel implements ActionListener,Runnable
{
private JButton but1,but2;
private JTextField text1,text2,text3,text;
private JLabel lab1,lab2,lab3,lab4;
private int hour,minute,second;
String ho,mu,se;
Thread t;
boolean flag=true;
public jishi()
{
but1=new JButton("start");
but2=new JButton("end");
lab1=new JLabel("hours");
lab2=new JLabel("minutes");
lab3=new JLabel("seconds");
lab4=new JLabel("times count");
but1.addActionListener(this);
but2.addActionListener(this);
this.add(lab1); this.add(text1);
this.add(lab2); this.add(text2);
this.add(lab3); this.add(text3);
this.add(lab4); this.add(text);
}
public void actionPerformed(ActionEvent e)
{
Object c=e.getSource();
if(c==but1)
{ String s=but1.getLabel();
t=new Thread(this);
t.start();
if(s.equals("pause"))
{ t.suspend();
but1.setLabel("start");
}
else {t.resume(); but1.setLabel("pause");}
}
else if(c==but2)
{ t.stop();
new dialoge();
}
}
public void run()
{
ho=text1.getText();
mu=text2.getText();
se=text3.getText();
hour=Integer.parseInt(ho);
minute=Integer.parseInt(mu);
second=Integer.parseInt(se);
if(minute==0&second==0)
{ hour=hour-1;
minute=59;
second=60;
}
while(flag)
{
second--;
if(second==0&minute!=0)
{ minute--;
second=59;
}
if(minute==0&hour!=0)
{ hour--;
minute=59;
}
if(hour==0&minute==0&second==0) flag=false;
text.setText(String.valueOf(hour)+":"+String.valueOf(minute)+":"+String.valueOf(second));
try
{ Thread.sleep(1000);
}catch(InterruptedException e){return;}
}
//JOptionPane.showMessageDialog(null,"时间到");
new dialoge();
}
}
class dialoge extends JDialog implements ActionListener
{
JButton ok;
JPanel pan;
JLabel la;
AudioStream as;
public dialoge()
{
try
{ InputStream in=new FileInputStream("爱你一定很快乐.mid");
as=new AudioStream(in);
}catch(Exception e){e.printStackTrace();}
setTitle("message");
ok=new JButton("yes");
ok.addActionListener(this);
la=new JLabel("GAME OVER",JLabel.CENTER);
pan=new JPanel();
pan.setLayout(new BorderLayout());
pan.add(la,BorderLayout.CENTER);
pan.add(ok,BorderLayout.SOUTH);
getContentPane().add(pan);
setSize(250,200);
setLocation(300,250);
setVisible(true);
if(as!=null)
AudioPlayer.player.start(as);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==ok)
{ AudioPlayer.player.stop(as);
setVisible(false);
}
}
}