I'm writing an application that has an SWT GUI currently, but would like the end-users to be able to choose between SWT and Swing. I've experimented with abstracting the GUI details before at different layers in the program, but have never been really satisfied with the results. Is there an agreed-upon or nice way to do this?
Unfortunately I don't believe there's a toolkit-agnostic API or similar.
So perhaps it's worth looking at the model-view-controller pattern. You need to abstract as much functionality away from the GUI into the controller such that the GUI components are thin and are dedicated to the particular windowing toolkit that you've chosen.
This will allow you to slot in a Swing view in place of a GWT view (or vice versa) with the minimum of duplicated code.
Note also that this makes testing a lot easier, since as much as possible has been folded into the controller or model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With