线程“main”中的异常java.awt.AWTError:未找到辅助技术:com.sun.java.accessibility.AccessBridge错误

时间:2014-03-17 12:48:52

标签: java swing

这是我的计划:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;


public class Userlogin{

Connection con;
Statement st;
ResultSet rs;

JFrame f = new JFrame("User Login");
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
JLabel lbl = new JLabel("Username");
JLabel lbl2 = new JLabel("Password");
JTextField tf = new JTextField(10);
JPasswordField pw = new JPasswordField(10);
JButton btn = new JButton("Login");

public Userlogin(){

    connect();
    displayFrame();
    loginButton();

}
public void connect(){

    try{

        String drv = "sun.jdbc.odbc.JdbcOdbcDriver";
        Class.forName(drv);
        String db = "jdbc:odbc:dbdbdoo";
        con = DriverManager.getConnection(db);
        st = con.createStatement();

    }

    catch(Exception ex){

        JOptionPane.showMessageDialog(null,"Bad Connection!");
        System.exit(0);

    }
}

public void displayFrame(){
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(300,150);
    f.setLocation(500,300);
    f.setVisible(true);
    f.setLayout(new GridLayout(3,1));

    f.add(p1);
    p1.add(lbl);
    p1.add(tf);

    f.add(p2);
    p2.add(lbl2);
    p2.add(pw);

    f.add(p3);
    p3.add(btn);

}

public void loginButton(){
    btn.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
             String user = tf.getText().trim();
             String pass = pw.getText().trim();

             try{

                String sql = "SELECT user, pass from userTable where user = '"+user+"' and pass = '"+pass+"'";
                rs = st.executeQuery(sql);

                int count = 0;

                while(rs.next()){

                    count++;
                }

                if(count==1){

                    JOptionPane.showMessageDialog(null,"Access Granted");
                    f.setVisible(false);
                    new FileMain();

                }

                else{

                    JOptionPane.showMessageDialog(null,"Access your face!");
                    System.exit(0);
                }
             }

             catch(Exception ex){

             }
        }

    });

}

    public static void main(String[] args){

        new Userlogin();
    }

}
编译后

显示错误:

--------------------配置:--------------------

Exception in thread "main" java.awt.AWTError: Assistive Technology not found:   com.sun.java.accessibility.AccessBridge
at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:775)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:861)
at java.awt.Window.getToolkit(Window.java:1127)
at java.awt.Window.init(Window.java:369)
at java.awt.Window.<init>(Window.java:407)
at java.awt.Frame.<init>(Frame.java:402)
at javax.swing.JFrame.<init>(JFrame.java:207)
at Userlogin.<init>(Userlogin.java:13)
at Userlogin.main(Userlogin.java:114)

流程已完成。

2 个答案:

答案 0 :(得分:1)

可能是Access Bridge的问题。

要解决您的特定问题,请按照http://docs.oracle.com/javase/accessbridge/2.0.2/setup.htm中的说明下载并安装Oracle Access Bridge。这应该可以解决程序中发生的启动错误。

答案 1 :(得分:0)

某些辅助功能应用启用了访问桥,但在卸载时忘记禁用它(应用示例:NVDA)。

如果您不想在 Windows 中安装 Oracle Access Bridge,则:

  • 查找访问桥设置文件:C:\Users\current_user\.accessibility.properties
  • 用文本编辑器打开并用起始文本注释每一行:#
  • 或者只是删除该文件。