java使用或覆盖了已过时的API_提示使用或覆盖了已过时的API,怎么办呢?找也找不到啊。...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

代码是这样的:

import java.awt.EventQueue;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement; import javax.swing.JButton; import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class AddUser extends JFrame { /**

* Launch the application

* @param args

*/

/**

* Create the frame

*/

String[] a=new String[3];

public AddUser() {

super();

getContentPane().setLayout(null);

setBounds(100, 100, 500, 375);

setTitle("添加用户");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel label = new JLabel();

label.setText("用户 ID");

label.setBounds(39, 54, 66, 18);

getContentPane().add(label); final JLabel label_1 = new JLabel();

label_1.setText("用 户 名");

label_1.setBounds(39, 93, 66, 18);

getContentPane().add(label_1); final JLabel label_2 = new JLabel();

label_2.setText("密 码");

label_2.setBounds(39, 137, 66, 18);

getContentPane().add(label_2); final JLabel label_3 = new JLabel();

label_3.setText("重复密码");

label_3.setBounds(39, 178, 66, 18);

getContentPane().add(label_3);

final JTextField textField = new JTextField();

textField.setBounds(136, 52, 159, 22);

getContentPane().add(textField);

//ID final JTextField textField_1 = new JTextField();

textField_1.setBounds(136, 91, 159, 22);

getContentPane().add(textField_1);

//name final JPasswordField passwordField = new JPasswordField();

passwordField.setBounds(136, 135, 159, 22);

getContentPane().add(passwordField);

//password

final JPasswordField passwordField_1 = new JPasswordField();

passwordField_1.setBounds(136, 176, 159, 22);

getContentPane().add(passwordField_1)

final JButton button = new JButton();

button.addActionListener(new ActionListener() {

public void actionPerformed(final ActionEvent e)

{

if(e.getActionCommand().equals("添加")) ;

{

a[0]=textField.getText();

a[1]=textField_1.getText();

a[2]=passwordField.getText();

String sql="insert into usert values('"+a[1]+"','"+a[2]+"','"+a[0]+"') "

System.out.print(sql);

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:huji","sa","");

System.out.print("aaaaaaaaaa");

Statement stmt = con.createStatement();

if(con!=null)

{

stmt.executeUpdate(sql);

new into();

}

stmt.close();

con.close();

}

catch(ClassNotFoundException a)

{}

catch(SQLException a)

{}

}

}}

);

button.setText("添加");

button.setBounds(79, 258, 106, 28);

getContentPane().add(button); final JButton button_1 = new JButton();

button_1.addActionListener(new ActionListener()

{

public void actionPerformed(final ActionEvent e)

{ if(e.getActionCommand().equals("取消"))

setVisible(false);

}

});

button_1.setText("取消");

button_1.setBounds(242, 258, 106, 28);

getContentPane().add(button_1);

setVisible(true);//

}

}

拜托了,谢谢啊~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值