运行时出错,这是怎么回事呢

import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class  Luck  extends JFrame implements ActionListener
{
JButton button;
JLabel  result;
JTextField resulttext;
    JPanel panel1,panel2;

public Luck()
{
super("中奖");
Container c=getContentPane();
c.setLayout(new FlowLayout(FlowLayout.CENTER));

        button=new JButton("抽奖");
result=new JLabel("结果");
result.setToolTipText("result");
resulttext=new JTextField("",16);

button.addActionListener(this);

        panel1=new JPanel();
panel1.add(button);

panel2=new JPanel();
panel2.add(result);
panel2.add(resulttext);

        c.add(panel1);
c.add(panel2);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(280,120);
this.setVisible(true);
}

public void actionPerformed(ActionEvent e)
{
int number;
number=(int)(Math.random()*10);

switch(number)
{
case 1:resulttext.setText("你长的很帅气");break;
case 2:resulttext.setText("你即将走桃花运");break;
case 3:resulttext.setText("你是个好人");break;
case 4:resulttext.setText("走好运,你就下次来");break;
case 5:resulttext.setText("下次吧你");break;
case 6:resulttext.setText("努力学习 下次再来");break;
case 7:resulttext.setText("你今天运气不佳");break;
case 8:resulttext.setText("奋斗");break;
case 9:resulttext.setText("恭喜你中奖了");break;
case 0:resulttext.setText("以后再回来吧");break;
}
}
public static void main(String[] args)
{
Luck application=new Luck();
}
}

你可能感兴趣的:(java,C++,c,swing,C#)