Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • oh, so that's how it is... May I ask another question?, what if there were more than one Apple variable?? Commented Oct 11, 2012 at 21:08
  • 2
    Not sure what you are trying to do, but if you are just trying to get all of the fields of type Apple you probably have to use Class.getDeclaredFields() to get all the fields and then loop through those to see which ones are of type Apple. Commented Oct 11, 2012 at 21:15
  • I see, at the beginning I thought that knowing how to get one instance of one of the fields would be enough, so didn't really make my question clear. I'm actually making a class that "builds" a swing gui from a class, so it will get all the components like JButton, JTextField, etc. So I was wondering if it will work like ..: JComponent jcomponent = (JComponent) field.get(ClassExtendedFromJFrame); something like this.. (it's a little bit confusing). I'll keep trying, and see what will it return, I'll try the looping solution too, thanks for your help. Commented Oct 11, 2012 at 21:23