java 从swing读取信息输入SQL server

package 各界面;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;

public class Login extends JFrame{
private JPanel p;
private JButton Entry,Register,Clear;
private JLabel user,password,hint;
private JTextField u1;
private JPasswordField w1;
public Login(){
super("图书馆管理系统");
p=new JPanel(null);
ImageIcon pic=new ImageIcon("image\02.png");
Entry=new JButton("登录");
Register=new JButton("注册");
Clear=new JButton("重置");
user=new JLabel("用户名:");
password=new JLabel("密码:");
hint=new JLabel();
u1=new JTextField(20);
w1=new JPasswordField(20);
w1.setEchoChar('*');

    user.setBounds(30,90,60,25);
    u1.setBounds(95,90,150,25);
    password.setBounds(30,120,60,25);
    w1.setBounds(95,120,150,25);
    Entry.setBounds(60,215,60,25);
    Register.setBounds(125,215,60,25);
    Clear.setBounds(190,215,60,25);
    hint.setBounds(60,185,180,25);



    Entry.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            SQL2008 entry=new SQL2008();
            String user=u1.getText();
            if(user==null||user.equals("")){
                hint.setText("用户名和密码不能为空!");
                return;
            }
            String password=new String(w1.getPassword());
            if(password==null||password.equals("")){
                hint.setText("密码不能为空:");
                return;
            }
            hint.setText("登录成功");
        }
    });

    Clear.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            u1.setText("");
            w1.setText("");

        }
    });



    this.add(p);
    p.add(Entry);
    p.add(Register);
    p.add(Clear);
    p.add(user);
    p.add(u1);
    p.add(password);
    p.add(w1);
    p.add(hint);
    this.setSize(400,300);
    this.setLocation(600,600);
    this.setIconImage(pic.getImage());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);
    this.setIconImage(pic.getImage());
}

public static void main(String[] args) {
    new Login();

}

}

写了一个粗略的界面,想把用户点击注册后,在注册画面输入的数据同步到数据库

新手,求大神

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问