I am using refection to get the declared fields of a class. Now I need to select only those which are UI components, for example JLabel, JFrame, etc. Is there a way to be able to determine whether a particular type extends java.awt.Compoenent?
I did manage to get the generic type of the field, however what i need is to be able to determine whether the field extends component
I’ve written an example of how to do this.
Find below the class being investigated:
And here is the code that checks the fields of this class:
Output: