为了账号安全,请及时绑定邮箱和手机立即绑定

想点击文本框的时候 文本框内容制空 不知道错在哪 (两处报错)

想点击文本框的时候 文本框内容制空 不知道错在哪 (两处报错)

启文羊习 2016-05-16 10:09:48
import  不缺public class Login extends JDialog {    boolean flag= false;    DatabaseLink dbc;    Vector ve;    JLabel lblWelcome = new JLabel();    JLabel lblPassword = new JLabel();    JLabel lblID = new JLabel();    JComboBox cboID = new JComboBox();    JPasswordField pawPassword = new JPasswordField();    JButton btnCancel = new JButton();    JButton btnOK = new JButton();    JLabel lblIcon = new JLabel();    JTextField txtID = new JTextField();    public Login(DatabaseLink dbc) {        try {            this.dbc=dbc;            setDefaultCloseOperation(DISPOSE_ON_CLOSE);            jbInit();        } catch (Exception ex) {            ex.printStackTrace();        }    }    private void jbInit() throws Exception {        this.setTitle("");        this.getContentPane().setLayout(null);        this.getRootPane().setDefaultButton(this.btnOK);                      /*  cboID.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));        cboID.setToolTipText("人员编号");        cboID.setBounds(new Rectangle(135, 60, 140, 30));        cboID.setEditable(true);*/                txtID.setFont(new java.awt.Font("Dialog", Font.PLAIN, 13));        txtID.setToolTipText("登录账号");        txtID.setText("--请输入登录账号--");        txtID.setBounds(new Rectangle(125, 130, 130, 30));        txtID.addMouseListener(new Login_txtID_mouseAdapter(this));                this.getContentPane().add(lblID);       // this.getContentPane().add(cboID);        this.getContentPane().add(lblPassword);        this.getContentPane().add(pawPassword);        this.getContentPane().add(btnCancel);        this.getContentPane().add(btnOK);        this.getContentPane().add(lblWelcome);                this.getContentPane().add(txtID);        ve = dbc.getInfo("select UID from employee order by UID");//从数据库中返回所有的人员编号        for (int i = 0; i < ve.size(); i++) {            cboID.addItem(ve.get(i));//向JComboBox中添加人员编号        }    }    public void btnOK_actionPerformed(ActionEvent e) {        int id = cboID.getSelectedIndex();        if(id==0){            JOptionPane.showMessageDialog(this, "请输入人员编号。", "账号有误",                                          JOptionPane.ERROR_MESSAGE);            return;        }        String str_ID = (String) cboID.getSelectedItem();        String str_Password = String.valueOf(pawPassword.getPassword());        String[] re = new String[2];        re = dbc.passwordValidate(str_ID);        if ( str_Password.equals(re[1] )) {//登陆成功            NowUser.userID = str_ID;            NowUser.userPower = re[0];            NowUser.password = str_Password;            flag = true;            this.dispose();         public void txtID_mouseClicked(MouseEvent e) {                if (txtID.getText().equals("--请输入登录账号--")) {                    txtID.setText("");                                             //   报错Multiple markers at this line   txtID_mouseClicked                }                                       //      - Duplicate local variable e                                                                                             //   - Syntax error on token "(", ; expected                                                                                              //   - void is an invalid type for the variable             }                          MainFrame frame = new MainFrame(dbc);            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();            Dimension frameSize = frame.getSize();            screenSize = Toolkit.getDefaultToolkit().getScreenSize();            frameSize = frame.getSize();            if (frameSize.height > screenSize.height) {                frameSize.height = screenSize.height;            }            if (frameSize.width > screenSize.width) {                frameSize.width = screenSize.width;            }            frame.setLocation((screenSize.width - frameSize.width) / 2,                              (screenSize.height - frameSize.height) / 2);            frame.setVisible(true);        } else {            JOptionPane.showMessageDialog(this, "请输入正确的密码。", "密码错误",                                          JOptionPane.ERROR_MESSAGE);            pawPassword.selectAll();            pawPassword.requestFocus(true);        }    }    public void btnCancel_actionPerformed(ActionEvent e) {        System.exit(0);    }}class Login_btnOK_actionAdapter implements ActionListener {    private Login adaptee;    Login_btnOK_actionAdapter(Login adaptee) {        this.adaptee = adaptee;    }    public void actionPerformed(ActionEvent e) {        adaptee.btnOK_actionPerformed(e);    }}class Login_btnCancel_actionAdapter implements ActionListener {    private Login adaptee;    Login_btnCancel_actionAdapter(Login adaptee) {        this.adaptee = adaptee;    }    public void actionPerformed(ActionEvent e) {        adaptee.btnCancel_actionPerformed(e);    }}class Login_txtID_mouseAdapter extends MouseAdapter {    private Login adaptee;                                                     //报错The method txtID_mouseClicked(MouseEvent) is                                                                                                     undefined for the type Login                                                                                                                                   //    Login_txtID_mouseAdapter(Login adaptee){        this.adaptee = adaptee;    }    public void mouseClicked(MouseEvent e) {        adaptee.txtID_mouseClicked(e);    }}
查看完整描述

1 回答

?
扬州灬炒饭

TA贡献7条经验 获得超3个赞

截图要比你这大段截代码效果好一点.....用于页面构建和控件呈现的代码就没必要贴出来了,把  相关控件的 变量名 和 点击事件里的业务逻辑代码贴出来就好了。你这一长串,并不知道重点是个啥

查看完整回答
反对 回复 2016-06-19
  • 1 回答
  • 0 关注
  • 1471 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信