Reputation: 18521
I am writing in java swing and I am wondering if there is a better(shorter) way to bind my object to the gui forms.
I will describe this need for an example - Zero Button :
Lets say I want on the GUI to have a number field and a button that puts zero in it. That's it.
I have a gui - form and java class . and a module class that holds all the data and does some logic.
What I will usually do (and I think its awful) is :
This whole process just to put a zero in the field next to it :-0).
and now for each field...
This is waaaay to long for me .
(Sometimes i just want to set the module to zero and than set the gui text to zero in two simple lines of code)
Is this the best practice?
Thanks.
Upvotes: 0
Views: 896
Reputation: 114777
Best practise to me is to choose a databinding framework and use it consequently. Databinding is exactly what you want - a synchronization between model (sic!) and UI
Here's a Q/A page on SO that includes a lot of links to databinding frameworks for Java Swing applications.
Upvotes: 2