ActionEvent 文本字段检查
我有带有属性 pin、发件人姓名、接收者姓名、发件人电话、金额的 cashform 和带有属性 pin、发件人姓名、接收者姓名、发件人电话、金额、银行名称、帐号的另一个表单 accountfrom 。
两种形式都有 send 命令 现在,我想检查当用户单击发送按钮时文本字段是否为空...
我以这种方式尝试过
if ( ae.getCommand() == send && ae.getSource()==cashpayform){
cashcheck();
}
if ( ae.getCommand() == send && ae.getSource()==accpayform){
acccheck();
}
,但它不起作用任何人都可以帮助我 谢谢
I have cashform with atttributes pin,sendername,receivername,senderphone,amount and another form accountfrom with attributes pin,sendername receivername,senderphone,amount,bankname,account number..
both form have send Command
Now, I want to check whether the textfields are empty when the user clicks send button...
I tried it in this way
if ( ae.getCommand() == send && ae.getSource()==cashpayform){
cashcheck();
}
if ( ae.getCommand() == send && ae.getSource()==accpayform){
acccheck();
}
but its not working can anyone help me
thanx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当命令触发事件时,事件源是命令而不是按钮,因此您无法从物理上区分按下按钮触发的命令和菜单触发的命令。
如果您需要区分命令的来源,我建议您使用两个不同的命令,如果您进行指针比较,它们可以具有相同的名称甚至 ID。
When a command triggers an event the source of the event is the Command not the button so you can't physically make a distinction between a command triggered from a button press and a command triggered from a menu.
I suggest you use two different commands if you need to make a distinction between the source of the commands, they can have the same name and even ID if you make pointer comparisons.
不要使用
==
比较字符串,而是使用 ..Don't compare strings using
==
, instead use..