📄 xuanhaoqi.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.Random;
public class XuanHaoQi extends Applet implements ActionListener{
int i;
TextField text[]=new TextField[7];
Button xuanHao=new Button("选号");
TextField textfield=new TextField(20);
public void init(){
setLayout(null);
i=0;
for(int j=0;j<6;j++){
text[j]=new TextField(2);
text[j].setBounds(60+30*j,20,20,20);
add(text[j]);
text[j].setEditable(false);
}
text[6]=new TextField(2);
text[6].setBounds(60,50,20,20);
add(text[6]);
text[6].setEditable(false);
xuanHao.setBounds(180,50,40,20);
add(xuanHao);
xuanHao.addActionListener(this);
textfield.setBounds(45,80,150,20);
add(textfield);
textfield.setEditable(false);
setBackground(Color.blue);
}
public void actionPerformed(ActionEvent e){
if(i>6){
for(int a=0;a<7;a++) text[a].setText("");
i=0;
}
if(i==6){
String temp="";
int result=(int)((new Random().nextDouble())*16)+1;
if(result<10) temp="0"+result;
else temp=""+result;
text[i].setText(temp);
textfield.setText("选特别号码为:"+temp+"。");
}
if(i<6){
String temp="";
int result=(int)((new Random().nextDouble())*33)+1;
if(result<10) temp="0"+result;
else temp=""+result;
textfield.setText("选基本号码"+(i+1)+"为:"+temp+"。");
for(int j=i;j>0;j--){
if(temp.equals(text[j-1].getText())){
textfield.setText("出现重复号码,重新选号。");
for(int a=0;a<7;a++) text[a].setText("");
i=0;
break;
}
}
text[i].setText(temp);
}
i++;
}
public void paint(Graphics g){
g.setColor(Color.yellow);
g.drawString("中国福彩自动选号器",70,15);
g.drawString("基本号码:",5,30);
g.setColor(Color.white);
g.drawString("特别号码:",5,60);
g.drawString("状态:",5,90);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -