📄 newuser.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class NewUser extends JFrame implements ActionListener
{
JLabel[] Jl={new JLabel("您的帐号"),new JLabel("初始密码"),
new JLabel(" 恭喜你,开户成功"),
new JLabel("请记您的用户名和密码"),
new JLabel("点击确认进入操作窗口")
};
JTextField []Jt={new JTextField("",8),new JTextField("888888",8),
};
JButton Jbtn=new JButton("确认");
Container c;
static String count=null;
public NewUser()
{
super("开户成功");
c=getContentPane();
c.setLayout(new BorderLayout());
/*数据库判断*/
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//声明驱动程序
String url="jdbc:odbc:info";//指定数据源名
Connection con=DriverManager.getConnection(url);//连接数据库
PreparedStatement stm=con.prepareStatement
("select 帐户 from 客户信息");
ResultSet result=stm.executeQuery();
while(result.next())
{
count=result.getString(1);
}
Jt[0].setText(count);
con.close();
}catch(Exception ev){}
JPanel []Jp={new JPanel(),new JPanel()};
Jp[0].setLayout(new GridLayout(2,2));
Jp[1].setLayout(new GridLayout(3,1));
for(int i=0;i<Jt.length;i++)
{
Jp[0].add(Jl[i]);
Jp[0].add(Jt[i]);
}
Jp[1].add(Jl[3]);
Jp[1].add(Jl[4]);
Jp[1].add(Jbtn);
Jbtn.addActionListener(this);
c.add(Jl[2],BorderLayout.NORTH);
c.add(Jp[0],BorderLayout.CENTER);
c.add(Jp[1],BorderLayout.SOUTH);
setSize(250,200);
show();
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Jbtn)
{
this.dispose();
new UserOP(count);
}
}
public void windowClosed(WindowEvent e)
{
new UserOP(count);
}
public void windowActivated(WindowEvent e)
{
}
public void windowClosing(WindowEvent e)
{
}
public void windowDeactivated(WindowEvent e)
{
}
public void windowDeiconified(WindowEvent e)
{
}
public void windowIconified(WindowEvent e)
{
}
public void windowOpened(WindowEvent e)
{
}
public static void main(String args[])
{
new NewUser();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -