📄 kaijiang.java
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.sql.*;
class Zp extends Frame implements ActionListener
{ Box baseBox,box1,box2,box3;
Label l1,l2,l3,l4,l5,l6;
TextField t1,t2,t3,t4,t5;
Button b1,b2;
Color backColor;
Zp(String s)
{ super(s);
box1=Box.createVerticalBox();
l1=new Label("欢迎登陆开奖信息系统");
l1.setBackground(Color.pink);
l1.setForeground(Color.red);
box1.add(l1);
box1.add(Box.createVerticalStrut(10));
l2=new Label("彩票编号");
box1.add(l2);
box1.add(Box.createVerticalStrut(10));
t1=new TextField(10);
box1.add(t1);
box1.add(Box.createVerticalStrut(10));
b1=new Button("查询");
b1.addActionListener(this);
box1.add(b1);
box1.add(Box.createVerticalStrut(10));
b2=new Button("退出");
b2.addActionListener(this);
box1.add(b2);
box1.add(Box.createVerticalStrut(10));
box2=Box.createVerticalBox();
l3=new Label("中奖号码个数");
l3.setBackground(Color.green);
box2.add(l3);
box2.add(Box.createVerticalStrut(10));
l4=new Label("开奖等级");l4.setBackground(Color.green);
l4.setForeground(Color.blue);
box2.add(l4);
box2.add(Box.createVerticalStrut(10));
l5=new Label("开奖日期");l5.setBackground(Color.green);
box2.add(l5);
box2.add(Box.createVerticalStrut(10));
l6=new Label("开奖金额");l6.setBackground(Color.green);
l6.setForeground(Color.blue);
box2.add(l6);
box2.add(Box.createVerticalStrut(10));
box3=Box.createVerticalBox();
t2=new TextField(10);
box3.add(t2);
box3.add(Box.createVerticalStrut(10));
t3=new TextField(10);
box3.add(t3);
box3.add(Box.createVerticalStrut(10));
t4=new TextField(10);
box3.add(t4);
box3.add(Box.createVerticalStrut(10));
t5=new TextField(10);
box3.add(t5);
box3.add(Box.createVerticalStrut(10));
baseBox=Box.createHorizontalBox();
baseBox.add(box1);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(box2);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(box3);
setLayout(new FlowLayout());
add(baseBox);
setBackground(Color.yellow);
setBounds(200,150,400,280);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
Connection con;
Statement sm;
ResultSet rs;
if(e.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e1)
{}
String sql="SELECT * FROM 中奖彩票信息查询 where 彩票编号='"+t1.getText()+"'";
try{
con=DriverManager.getConnection("jdbc:odbc:sun","","");
sm=con.createStatement();
rs=sm.executeQuery(sql);
while(rs.next())
{ String s2=rs.getString(2);
String s3=rs.getString(3);
String s4=rs.getString(4);
String s5=rs.getString(5);
t2.setText(s2);
t3.setText(s3);
t4.setText(s4);
t5.setText(s5);
}}
catch(Exception e2){}
}
else if(e.getSource()==b2)
{setVisible(false);}
} }
public class Kaijiang
{ public static void main(String args[])
{ Zp caipiao=new Zp("开奖信息管理系统");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -