I want to add to a Java JFrame a list of my class’s fields names, along with their respective values. Those fields can of course change value during the program’s execution and i want this change to be displayed dynamically in my GUI. If for example i have a field private int networkId; in a class BaseStation, how can i make it appear in the frame of a class BaseStationFrame?
I want to add to a Java JFrame a list of my class’s fields
Share
If you want your UI to have access to private fields of your class, you won’t have much options
PropertyChangeEvents when those fields change.Your UI can then use the getter to obtain the initial value, and use the events to update the UI when the value of a field has been changed. You could even write a fairly generic UI component for this by using reflection to obtain all the getters, but if it is only for a few classes this might be overkill