java登录注册界面不要数据库

可运行

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class SignIn extends JFrame implements Serializable{
private JLabel ab1,ab2,ab3;
private JTextField t1;
private JPasswordField pass;
private JButton bt1,bt2,bt3;
private JPanel jp1,jp2,jp3;
private static final long serialVersionUID = 16L;
SignIn(){
this.setTitle("界面测试");
this.setLayout(new GridLayout(4,1));
this.setResizable(false);
this.setBounds(300,300,300,300);
this.setDefaultCloseOperation(3);
init();
this.setVisible(true);
}
private void init() {
ab1=new JLabel("百度知道XX系统",JLabel.CENTER);
ab2=new JLabel("昵称:");
ab3=new JLabel("密码:");
t1=new JTextField(15);
pass=new JPasswordField(15);
bt1=new JButton("登陆");
bt2=new JButton("退出");
bt3=new JButton("注册");
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
jp1.add(ab2);
jp1.add(t1);
jp2.add(ab3);
jp2.add(pass);
jp3.add(bt1);
jp3.add(bt2);
jp3.add(bt3);
event();
this.add(ab1);
this.add(jp1);
this.add(jp2);
this.add(jp3);
}
private void event() {
bt2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(1);
}
});
}
public static void main(String[] args) {
new SignIn();
}
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-12-28
连接ACCESS可以用 jdbc-odbc桥, 先在控制面板-管理工具-数据源,里建立一个ACCESS的数据源 在JAVA里调用CLASS的静态方法forName Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") 这个有可能发生异常,所有要用try catch 之后是连接到数据库 利用java.sql包中的Connection声明一个对象,然后用类DriverManager调用它 的静态方法getConnection创建连接对象 Connection con=DriverManager.getConnection("jdbc:odbc:数据源名字","用户名","密码"),数据库没密码的话""里面什么也不添 连接数据库的时候要捕获SQLException异常本回答被网友采纳
第2个回答  2018-12-28
你好,是网页?还是桌面程序?
相似回答