java 基于swing登录注册界面设计并连接数据库

package c1;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import sun.security.util.Password;

//import sun.security.util.Password;

import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.Graphics;

import javax.swing.JTextField;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
import java.awt.Color;

public class Loginandr extends JFrame {

	private JPanel contentPane;
	private JTextField usertextField;
	private JPasswordField passwordtext;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {

					Loginandr frame = new Loginandr();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Loginandr() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 646, 429);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 10, 632, 382);
		contentPane.add(tabbedPane);

		JPanel panel登录 = new JPanel() {
			
			protected void paintComponent(Graphics g) {
				// TODO Auto-generated method stub
				super.paintComponent(g);
				g.drawImage(new ImageIcon("D:\\JA2021\\Di11\\img\\u.jfif").getImage(), 0, 0,
						getWidth(), getHeight(), this);
			}	
		};
		tabbedPane.addTab("登录 ", null, panel登录, null);
		panel登录.setLayout(null);

		usertextField = new JTextField();
		usertextField.setBounds(213, 35, 204, 37);
		panel登录.add(usertextField);
		usertextField.setColumns(10);

		JLabel lblNewLabel_1 = new JLabel("\u5BC6\u7801:");
		lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		lblNewLabel_1.setBounds(81, 112, 108, 37);
		panel登录.add(lblNewLabel_1);

		JButton btnNewButton = new JButton("\u767B\u5F55");
		btnNewButton.setBackground(new Color(255, 204, 102));
		btnNewButton.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		btnNewButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			
			
			String str = usertextField.getText();
			String str2 = passwordtext.getText();
			
			
			//int flag = comboBox.getSelectedIndex();

			try {
				Class.forName("com.mysql.jdbc.Driver");
				Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/java", "root", "root");
				
				PreparedStatement pr;
				if (flag == 0) {
					pr = conn.prepareStatement(" select * from user where username=? ");
				} else {

					pr = conn.prepareStatement(" select * from user where password=? ");
				}

				pr.setString(1, str);
				ResultSet jieguo = pr.executeQuery();

				while (jieguo.next()) {
					int id = jieguo.getInt(1);
					String username = jieguo.getString(2);
					String password= jieguo.getString(3);
					

					Object[] tmp = { id, username, password};
					
				}

			} catch (ClassNotFoundException | SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
				
			}
		});
		btnNewButton.setBounds(213, 194, 77, 37);
		panel登录.add(btnNewButton);

		passwordtext = new JPasswordField();
		passwordtext.setBounds(213, 112, 204, 37);
		panel登录.add(passwordtext);
		
		JButton btnNewButton_1 = new JButton("\u91CD\u7F6E");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				usertextField.setText(null);
				 passwordtext.setText(null);
				
				
			}
		});
		btnNewButton_1.setBackground(new Color(255, 204, 102));
		btnNewButton_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		btnNewButton_1.setBounds(340, 194, 77, 37);
		panel登录.add(btnNewButton_1);
		
		JLabel lblNewLabel_1_1 = new JLabel("\u7528\u6237\u540D:");
		lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		lblNewLabel_1_1.setBounds(58, 35, 193, 31);
		panel登录.add(lblNewLabel_1_1);
		
		//设置窗口可见(默认Jrame创建时不可见的)
		this.setVisible(true);
		
	}
}

 

问题是?

问题是什么