| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 416 人关注过本帖
标题:为什么这个程序就是运行不了?
取消只看楼主 加入收藏
光明左使
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2006-8-16
收藏
 问题点数:0 回复次数:1 
为什么这个程序就是运行不了?

我实在是看不出问题,但是问题却是很大,请高手参详,
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class random extends JApplet implements ActionListener
{
JLabel oneLabel,twoLabel,threeLabel,fourLabel,fiveLabel,
sixLabel,sevenLabel,eightLabel,nineLabel,tenLabel,
elevenLabel,travelLabel;
JTextField oneField,twoField,threeField,fourField,fiveField,
sixField,sevenField,eightField,nineField,tenField,
elevenField,travelField;
JButton DiceButton;

int Dice = 0;
int a[] = new int [13];

public void init ()
{
Container container = getContentPane();
container.setLayout ( new FlowLayout () );

oneLabel = new JLabel ( "出现1的次数:" );
container.add ( oneLabel );
oneField = new JTextField ( 10 );
container.add ( oneField ) ;
oneField.setEditable ( false );

twoLabel = new JLabel ( "出现2的次数:" );
container.add ( twoLabel );
twoField = new JTextField ( 10 );
container.add ( twoField );
twoField.setEditable ( false );

threeLabel = new JLabel ( "出现3的次数:" );
container.add ( threeLabel );
threeField = new JTextField ( 10 );
container.add ( threeField );
threeField.setEditable ( false );

fourLabel = new JLabel ( "出现4的次数:" );
container.add ( fourLabel );
fourField = new JTextField ( 10 );
container.add ( fourField );
fourField.setEditable ( false );

fiveLabel = new JLabel ( "出现5的次数:" );
container.add ( fiveLabel );
fiveField = new JTextField ( 10 );
container.add ( fiveField );
fiveField.setEditable ( false );

sixLabel = new JLabel ( "出现6的次数:" );
container.add ( sixLabel );
sixField = new JTextField ( 10 );
container.add ( sixField );
sixField.setEditable ( false );

sevenLabel = new JLabel ( "出现7的次数:" );
container.add ( sevenLabel );
sevenField = new JTextField ( 10 );
container.add ( sevenField ) ;
sevenField.setEditable ( false );

eightLabel = new JLabel ( "出现8的次数:" );
container.add ( eightLabel );
eightField = new JTextField ( 10 );
container.add ( eightField );
eightField.setEditable ( false );

nineLabel = new JLabel ( "出现9的次数:" );
container.add ( nineLabel );
nineField = new JTextField ( 10 );
container.add ( nineField );
nineField.setEditable ( false );

tenLabel = new JLabel ( "出现10的次数:" );
container.add ( tenLabel );
tenField = new JTextField ( 10 );
container.add ( tenField );
tenField.setEditable ( false );

elevenLabel = new JLabel ( "出现11的次数:" );
container.add ( elevenLabel );
elevenField = new JTextField ( 10 );
container.add ( elevenField );
elevenField.setEditable ( false );

travelLabel = new JLabel ( "出现12的次数:" );
container.add ( travelLabel );
travelField = new JTextField ( 10 );
container.add ( travelField );
travelField.setEditable ( false );

DiceButton = new JButton ( "开始" );
container.add ( DiceButton );
DiceButton.addActionListener ( this );
}

public void actionPerFormed ( ActionEvent actionevent )
{
for ( int i=0;i<3600;i++ )
{
Dice = sumDice ();
a[Dice]++;
}

display (a) ;
}

public int sumDice ( )
{
int die1 = 1 + ( int )( Math.random()*6 ),
die2 = 1 + ( int )( Math.random()*6 ),
sum = die1 + die2;

return sum;
}

public void display (int b[])
{
oneField.setText ( Integer.toString ( b[1] ) );
twoField.setText ( Integer.toString ( b[2] ) );
threeField.setText ( Integer.toString ( b[3] ) );
fourField.setText ( Integer.toString ( b[4] ) );
fiveField.setText ( Integer.toString ( b[5] ) );
sixField.setText ( Integer.toString ( b[6] ) );
sevenField.setText ( Integer.toString ( b[7] ) );
eightField.setText ( Integer.toString ( b[8] ) );
nineField.setText ( Integer.toString ( b[9] ) );
tenField.setText ( Integer.toString ( b[10] ) );
elevenField.setText ( Integer.toString ( b[11] ) );
travelField.setText ( Integer.toString ( b[12] ) );
}
}



搜索更多相关主题的帖子: 运行 
2006-10-09 21:33
光明左使
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2006-8-16
收藏
得分:0 

好你就是说在引用了this之后,就出现了故障,我也说不清


以剑论道,以道搏剑,快意恩仇,却是何等的孤独!!
2006-10-09 22:12
快速回复:为什么这个程序就是运行不了?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017194 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved