📄 jxfs.java
字号:
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
class Rr extends Frame implements ActionListener
{
Label l1,l2,l3;
Button button1,button2,button3;
TextField t1,t2,t3,t4,t5,t6,t7,t8;
Color backColor;
Rr(String s)
{
super(s);
setLayout(new FlowLayout());
l1=new Label("祝你好运",Label.CENTER);
l1.setBackground(Color.red);
l2=new Label("请按开始按钮",Label.CENTER);
l2.setBackground(Color.yellow);
l3=new Label("请按结束按钮",Label.CENTER);
l3.setBackground(Color.yellow);
t1=new TextField(6);t2=new TextField(6);t3=new TextField(6);t4=new TextField(6);t5=new TextField(6);
t6=new TextField(6);t7=new TextField(6);t8=new TextField(6);
t8=new TextField(10);
button1=new Button("开始");
button2=new Button("结束");
button3=new Button("退出");
add(l1);add(l2);add(button1);add(t1);add(t2);add(t3);add(t4);add(t5);add(t6);add(t7);
add(l3);
add(button2); add(t8);add(button3);
setBackground(Color.cyan);
backColor=getBackground();
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
setBounds(150,150,200,200);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{ Connection con;
Statement sm;
ResultSet rs;
if(e.getSource()==button3){setVisible(false);}
if(e.getSource()==button1)
{ int i=1; int k[]=new int[8];
for( i=1;i<8;i++)
{k[i]=(int)(Math.random()*35);
}t1.setText(""+k[1]);t2.setText(""+k[2]);t3.setText(""+k[3]);t4.setText(""+k[4]);t5.setText(""+k[5]);
t6.setText(""+k[6]);t7.setText(""+k[7]);}
if(e.getSource()==button2)
{ t8.setText("购票结束");}
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sql="insert into 号码表 values('"+t1.getText()+"','"+
t2.getText()+"','"+t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"','"
+t6.getText()+"','"+t7.getText()+"')";
con=DriverManager.getConnection("jdbc:odbc:sun","","");
sm=con.createStatement();
sm.executeUpdate(sql);
}
catch(Exception e2){e2.printStackTrace();}
}
}
public class Jxfs
{
public static void main(String args[])
{
Rr caipiao=new Rr("欢迎使用机选方式");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -