導入Java . util . random;
導入Java . awt . *;
導入Java . awt . event . *;
公共類雙色球實現ActionListener{
int i,k;
靜態int rm,RR;
int[]a = new int[33];
幀f =新幀(“雙色球隨機數”);
TextField TF = new TextField();
Random rd = new Random();
公共雙色球()
{
for(I = 0;我& lt33;i++)
{
a[I]= I;
}
f . set layout(new BorderLayout());
f . addwindowlistener(new window adapter(){
公共void窗口關閉(WindowEvent e)
{
system . exit(0);
}
});
}
公共void init()
{
TF . addactionlistener(this);
按鈕b =新建按鈕(“開始”);
b . addactionlistener(this);
f.add(tf," North ");
f .添加(b);
f.setSize(300,300);
f . set visible(true);
}
公共無效操作已執行(操作事件e)
{
If(e.getActionCommand()。等於("開始"))
//TF . settext(" "+(rd . nextint(33)+1)+" "+(rd . nextint(33)+1)+" "+(rd . nextint(33)+1)+" "+(rd . nextint(33)+1)+" "+(rd .Nextint (33)+1)+"藍球號碼:"+(rd . nextint(15)+1));
{
/*rr = new Random()。nextInt(33);
rm = new Random()。nextInt(33);*/
for(I = 0;我& lt33;i++)
{
rr = new Random()。nextInt(33);
rm = new Random()。nextInt(33);
system . out . print(RR+" ");
k = a[RM];
a[RM]= a[RR];
a[RR]= k;
}
Tf.setText("紅球號碼:"+(A[0]+1)+"+(A[1]+1)+"+(A[2]+1)+"+。
}
}
公共靜態void main(String[]args)//引發異常
{
新雙色球()。init();
}
}