Jose, been awhile. I could write this code for you but that is not what you are asking. Answer is yes, but we could get some complaints from the small-tight-code department.
What you do is write a switch of some kind, it can be if()else but the matching of elses with the if's is tedious and error prone. The event usually has some sort of numeric, though recently I saw a
String datatype in Layout managers where we usually see ints. It's sorta involved, I am assigning you because of where you are at in asking the question to invest as much as five hours trying to figure it out before reposting.
It's skill building that you will need if you go on. Answer to your question is yes, it can be done.