ActionEvent 文本字段检查

发布于 2024-11-19 02:37:36 字数 426 浏览 6 评论 0原文

我有带有属性 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遇到 2024-11-26 02:37:36

当命令触发事件时,事件源是命令而不是按钮,因此您无法从物理上区分按下按钮触发的命令和菜单触发的命令。

如果您需要区分命令的来源,我建议您使用两个不同的命令,如果您进行指针比较,它们可以具有相同的名称甚至 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.

叹沉浮 2024-11-26 02:37:36

不要使用 == 比较字符串,而是使用 ..

send.equals(ae.getCommand())

Don't compare strings using ==, instead use..

send.equals(ae.getCommand())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文