java file gettext_【急】java无法获取到getText()的内容。

根据事件动作监听,= = 有两个文本框TextField text1,TextField text2;监听到的内容放到name和key中,当触发按钮事件时对name和key进行处理。。。不知道哪里写错了,getText()到的事件永远为空。部分代码如下:public void actionPerformed(ActionEvent e){if(e.getSource() == text1){name = text1.getText();}else if(e.getSource() == text2){key = text2.getText();}else if(e.getSource() == acButton1){if(name != null && key != null && name!="" && key!=""){openConnection(); //打开数据库的连接try{theStatement=theConnection.createStatement();theResult1 = theStatement.executeQuery("select * from UserTable where UserName="+name+" and UserPassword ="+key);}catch(Exception E){System.out.println("connect failed!"); System.out.println(E.toString()); E.printStackTrace(); }closeConnection(); //关闭已经打开的数据库if(theResult1 != null) //账户存在和密码正确{setVisible(false);Log log = new Log();log.setVisible(true);}else{Warning warn2 = new Warning(); //调用出错提示界面warn2.setVisible(true);}}else {theResult1 = null;Warning warn2 = new Warning(); //调用出错提示界面warn2.setVisible(true);}}else if(e.getSource() == acButton2)//注册界面{CreateAccount ct = new CreateAccount(); //调用注册界面ct.setVisible(true);}}

b9a78de697b9b0254f1949e182bd56ee.png

75c3e4ae303454b8c98dc2be2f2e2aae.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值