| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 658 人关注过本帖
标题:注: Loagin.java使用或覆盖了已过时的 API。怎么修改啊?求高手指点?
只看楼主 加入收藏
chen521125ll
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2012-12-7
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:2 
注: Loagin.java使用或覆盖了已过时的 API。怎么修改啊?求高手指点?
package wangqinglei;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;


public class Loagin extends JFrame implements ActionListener{

    /**
     * @param args
     */
    JLabel label1;
    JLabel label2;
    JLabel label3;
    JComboBox combo;
    JPasswordField textfield2;
    JButton button1;
    JButton button2;
    Connection conn;
    Object person[]={"tom","sara","jerry"};
    JPanel panel1=new JPanel();
    JPanel panel2=new JPanel();
    JPanel panel3=new JPanel();
   
    public Loagin(){
        setTitle("用户登录");
        setBounds(300,200,300,220);
        setVisible(true);
        //setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container c=getContentPane();
        c.setLayout(new BorderLayout());
        c.add(panel1,BorderLayout.NORTH);
        c.add(panel2,BorderLayout.CENTER);
        c.add(panel3,BorderLayout.SOUTH);
        //c.setBackground(Color.pink);
        //c.setLayout(new FlowLayout(1,3,10));
        label1=new JLabel("                   ");
        label1.setFont(new Font("华文行楷",Font.TYPE1_FONT,30));
        panel1.add(label1);
        panel2.setLayout(new FlowLayout(1,5,18));
        label2=new JLabel("           用户名:");
        panel2.add(label2);
        combo=new JComboBox(person);
        //combo.addItem(person);
        combo.setEditable(true);
        panel2.add(combo);
        label3=new JLabel("              码:");
        panel2.add(label3);
        textfield2=new JPasswordField(12);
        panel2.add(textfield2);
        button1=new JButton("登陆");
        button1.addActionListener(this);
        panel3.add(button1);
        button2=new JButton("清空");
        button2.addActionListener(this);
        panel3.add(button2);
        
        ProgressPanel propanel=new ProgressPanel();
        propanel.add(new JLabel("wait a second...."));
        //JScrollPane jsp=new JScrollPane(propanel);
        setGlassPane(propanel);
    }
    public void actionPerformed(ActionEvent e){
        if(e.getSource()==button2){
            //textfield1.setText("");
            //combo.removeAllItems();
            textfield2.setText("");
        }
        if(e.getSource()==button1){
            if(combo.getSelectedItem().equals("")){
                new JOptionPane().showMessageDialog(null,"用户名不能为空");
            }
            else if(textfield2.getText().equals("")){
                new JOptionPane().showMessageDialog(null, "密码不能为空");
            }
            else{
                String s1=(String) combo.getSelectedItem();
                String s2=textfield2.getText();
               
                try{
                    Class.forName("com.mysql.jdbc.Driver");
                    
                    conn = DriverManager.getConnection("jdbc:mysql://localhost/studentmanager?user=root&password=wql");
                    //System.out.print("745");
                    Statement stmt=conn.createStatement();
                    String sql="select * from user where username='"+s1+"' and password='"+s2+"'";
                    ResultSet rs = stmt.executeQuery(sql);
                    
                    if(rs.next()){
                        //System.out.print("Sucessfull");
                        getGlassPane().setVisible(true);
                        this.setVisible(false);
                        new MainPart();
                        
                    }
                    else{
                        new JOptionPane().showMessageDialog(null,"账号不存在,请检查后再输入!");
                    }
                           
                }catch(Exception e1){
                    System.err.print(e1.getMessage());
                }
               
            }
        }
        
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new Loagin();

    }

}

搜索更多相关主题的帖子: package person Object public 
2013-01-08 13:26
Kingbox_tang
Rank: 7Rank: 7Rank: 7
来 自:天津师范大学
等 级:黑侠
威 望:3
帖 子:146
专家分:677
注 册:2012-11-27
收藏
得分:10 
你把这个Loagin关键字换成别的试试。

旨在提高编程水平,学有所用,学有所成,学有所为。
2013-01-08 15:46
w527705090
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:441
专家分:1882
注 册:2011-6-28
收藏
得分:10 
楼上的解答肯定是错误的  并不是类名的问题
这个只是一个警告而已,你不要去管他,他只是告诉你你使用了已经过时的函数,不过不要紧,jdk是向下兼容的!
只要编译能通过就可以了

有心者,千方百计;无心者,千难万难。
2013-01-15 18:49
快速回复:注: Loagin.java使用或覆盖了已过时的 API。怎么修改啊?求高手指点?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017310 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved