📄 cmxx.java
字号:
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.sql.*;
class L extends Frame implements ActionListener
{ Box baseBox,box1,box2;
Label l1,l2,l3,l4,l5,l6,l7,l8,l9;
TextField t1,t2,t3,t4,t5,t6,t7,t8;
Button Zhuce;
Color backColor;
L(String s)
{
super(s);
box1=Box.createVerticalBox();
l8=new Label("带*号为可选项",Label.CENTER);
add(l8);
l8.setBackground(Color.green);
l1=new Label("彩民编号",Label.CENTER);
l1.setBackground(Color.green);
box1.add(l1);
box1.add(Box.createVerticalStrut(6));
l2=new Label("彩民姓名",Label.CENTER);
l2.setBackground(Color.yellow);
box1.add(l2);
box1.add(Box.createVerticalStrut(6));
l3=new Label("*彩民性别",Label.CENTER);
l3.setBackground(Color.yellow);
box1.add(l3);
box1.add(Box.createVerticalStrut(6));
l4=new Label("彩民年龄",Label.CENTER);
l4.setBackground(Color.cyan);
box1.add(l4);
box1.add(Box.createVerticalStrut(6));
l5=new Label("住址",Label.CENTER);
l5.setBackground(Color.cyan);
box1.add(l5);
box1.add(Box.createVerticalStrut(6));
l6=new Label("工作单位",Label.CENTER);
l6.setBackground(Color.red);
box1.add(l6);
box1.add(Box.createVerticalStrut(6));
l7=new Label("联系电话",Label.CENTER);
l7.setBackground(Color.red);
box1.add(l7);
box1.add(Box.createVerticalStrut(6));
l9=new Label("购票日期",Label.CENTER);
l9.setBackground(Color.red);
box1.add(l9);
box1.add(Box.createVerticalStrut(6));
box2=Box.createVerticalBox();
t1=new TextField(10);
t1.addActionListener(this);
box2.add(t1);
box2.add(Box.createVerticalStrut(10));
t2=new TextField(10);
t2.addActionListener(this);
box2.add(t2);
box2.add(Box.createVerticalStrut(10));
t3=new TextField(10);
t3.addActionListener(this);
box2.add(t3);
box2.add(Box.createVerticalStrut(10));
t4=new TextField(10);
box2.add(t4);
box2.add(Box.createVerticalStrut(10));
t5=new TextField(10);
box2.add(t5);
box2.add(Box.createVerticalStrut(10));
t6=new TextField(10);
box2.add(t6);
box2.add(Box.createVerticalStrut(10));
t7=new TextField();
box2.add(t7);
box2.add(Box.createVerticalStrut(10));
t8=new TextField();
box2.add(t8);
box2.add(Box.createVerticalStrut(10));
Zhuce=new Button("提交");
Zhuce.addActionListener(this);
box2.add(Zhuce);
Zhuce.setBackground(Color.cyan);
box2.add(Box.createVerticalStrut(10));
baseBox=Box.createHorizontalBox();
baseBox.add(box1);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(box2);
setLayout(new FlowLayout());
add(baseBox);
setBackground(Color.pink);
Zhuce.addActionListener(this);
setBounds(120,150,250,180);
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()==Zhuce)
{X f=new X("注册成功界面");}
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e1)
{}
String sql1="insert into 彩民信息表 values('"+t1.getText()+"','"+
t2.getText()+"','"+t3.getText()+"','"+t4.getText()+"','"+t5.getText()+"','"
+t6.getText()+"','"+t7.getText()+t8.getText()+"')";
try
{ {
con=DriverManager.getConnection("jdbc:odbc:sun","","");
sm=con.createStatement();
sm.executeUpdate(sql1);
}con.close();}
catch(Exception e2)
{e2.printStackTrace();}
}
}
public class Cmxx
{
public static void main(String args[])
{
new L("彩民信息管理系统");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -