Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java - Best way to display object properties

Reflection or hashmaps? Suppose you are writting a graphical application where you have objects lying around and users have the posibility of clicking on them. That said, you want to display the clicked object information somehow.

I end up reading Accessible interface from accessibility java package and AccessibleContext class... Before that, I wrote testing code using hash maps for properties instead of class fields. And lastly, I thought in Reflection after reading that JavaBeans use instrospection.

What would you recommend in such applications?

like image 929
Sebastian Avatar asked Nov 19 '25 09:11

Sebastian


1 Answers

Using reflection and introspection sounds like a better approach than using HashMaps. Instead of using this API directly, I would recommend an abstraction layer like Commons BeanUtils, which will allow you to work with classes adhering to the JavaBean standard in an easy manner.

Here's the User Guide complete with examples.

like image 61
nwinkler Avatar answered Nov 21 '25 23:11

nwinkler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!