Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SWITCH STATEMENT
 
Similar Threads
Applet Error java.lang.InternalError: couldn't create component peer
throw and throws
hibernate save object problem !
Event Handling
How to determine object type.