File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Event Handling
Applet Error java.lang.InternalError: couldn't create component peer
hibernate save object problem !
How to determine object type.
throw and throws