aspose file tools*
The moose likes Beginning Java and the fly likes SWITCH STATEMENT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SWITCH STATEMENT" Watch "SWITCH STATEMENT" New topic
Author

SWITCH STATEMENT

AaronMweu Munzaa
Greenhorn

Joined: Mar 04, 2004
Posts: 8
Hey Guys - Any help on this would be highly appreciated:
I am implementing actionPerformed()method and I wanted to use case statements to determine event source (I have buttons, textfields, checkboxes etc in my GUI)...Could anyone tell me how to determine event source(probably using getSource method) then pass it as the argument to my case statements...Please.
Thanks in Advance.
Aaron
Jeffrey Hunter
Ranch Hand

Joined: Apr 16, 2004
Posts: 305
You won't be able to use a switch here, since you'll be comparing event Objects.
For instance:

This is one way to do it, but regardless of which way you choose, you won't be able to use the switch (since switch statements require char, byte, short, or int datatype).
AaronMweu Munzaa
Greenhorn

Joined: Mar 04, 2004
Posts: 8
Thanx Hunter...Helped greatly appreciated.
Aaron
 
Don't get me started about those stupid light bulbs.
 
subject: SWITCH STATEMENT