I'm working to a Java project at uni and I have to stay loyal to object orientation as much as I can. So I have a doubt.
I have many windows with text fields and buttons and everytime I click on a button I need to check whether the text fields in frames are empty.
Now what I did was adding a new method in ActionListener classes and called it check(). This method checks what I said and if there are empty text fields it throws an exception that I created (let's say EmptyFieldsException).
Then I have a try/catch block in actionPerformed, calling the check method. If the exception is catched then a JOptionPane pops up.
My question is: is this a good way to handle such a problem (using exceptions)? Or is it actually overkill? Maybe I could have simply used an if statement in actionPerformed, I'm a bit confused about this.