亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

想點擊文本框的時候 文本框內容制空 不知道錯在哪 (兩處報錯)

想點擊文本框的時候 文本框內容制空 不知道錯在哪 (兩處報錯)

啟文羊習 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 關注
  • 1507 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號