0

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

RNZN
  • 107
  • 3
  • 12
  • Check if the spelling is same and wrap the "send" and "cashpayform" etc in quotes. And what are Cashcheck() and acccheck(). – Balanivash Jul 08 '11 at 10:41
  • ya the spell is same .. cashcheck and acccheck are method to check empty fields – RNZN Jul 08 '11 at 11:03
  • Try wrapping 'send' 'cashpayform' in quotes – Balanivash Jul 08 '11 at 11:05
  • Either ae.getCommand() does not equal send, or ae.getSource() does not equal cashpayform or accpayform. The problem is not in this code, it's some other place in your application. The best way to find out is to run with a debugger and set a breakpoint on the conditionals, and see why they're not triggering. – Jesse Barnum Jul 08 '11 at 12:54

2 Answers2

1

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.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
0

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

send.equals(ae.getCommand())
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433