当前位置: 代码迷 >> Java相关 >> 图形界面运行有一处异常
  详细解决方案

图形界面运行有一处异常

热度:96   发布时间:2016-04-22 21:29:47.0
图形界面运行有一处错误~求助
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
class GUIshow extends JFrame implements ActionListener,ItemListener,ChangeListener,Runnable
{
    JPanel pNorth=new JPanel();
    JPanel pBottom=new JPanel();
    JPanel pTime=new JPanel();
    JLabel pic;
    ImageIcon img;
    Thread thread1;
    Label prompt,ptime,pscore;
    TextField question,score,time;
    JPasswordField answer;
    Checkbox look;
    JcomboBox size;
    Container c;
    JSlider jslcolor;
    int cValue;
    String[][]game=new String[3][3];
    int i;
    int scores=0,score0=0;
    int times=50;
    GUIshow()
    {
          this.setTitle("图形界面设计示例--竞猜小游戏");
          thread1=new Thread(this,"timing");
          c=getContentPane();
          c.setLayout(new BorderLayout());
          prompt=new Label("****有奖竞猜啦!****");
          size=new JComboBox();
          size.addItem("1");
          size.addItem("2");
          size.addItem("3");
          question=new TextField(20);
          look=new Checkbox("明码显示密码",false);
          answer=new JPasswordField(10);
          PTime.setFont(new Font("黑体",Font.PLAIN,18));
          PTime.setForeground(Color.red);
          Ptime=new Label("剩余时间:");
          time=new TextField(6);
          psocre=new Label("目前得分:");
          score=new Textfield("0");
          pNorth.add(prompt);
          pNorth.add(size);
          pNorth.add(question);
          pNorth.add(look);
          pNorth.add(answer);
          look.addItemListener(this);
          size.addItemListener(this);
          c.add(pNorth,BorderLayout.NORTH);
          pTime.setLayout(new GridLayout(8,1));
          pTime.add(ptime);
          pTime.add(time);
          pTime.add(pscore);
          pTime.add(score);
          c.add(pTime,BorderLayout.EAST);
          img=new ImageIcon("normal.gif");
          pic=new JLabel(img);
          c.add(pic.BorderLayout.CENTER);
          jslcolor=new JSlider(JSlider.HORIZONTAL,0,255,100);
          jslcolor.setMajorTickSpacing(50);
          jslcolor.setPaintLabels(true);
          Button btStart=new Button("开始游戏");
          Button btOk=new Button("确定");
          Button btCancel=new Button("退出");
          Button btReward=new Button("奖品");
          pBottom.add(jslcolor);
          pBottom.add(btStart);
          pBottom.add(btOk);
          pBottom.add(btReward);
          pBottom.add(btCanel);
          jslcolor.addChangeListener(this);
          btStart.addActionLiatener(this);
          btOk.addActionListener(this);