Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a nice way to abstract the GUI so SWT or Swing can be used?

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?

like image 957
ZoFreX Avatar asked Jan 01 '10 20:01

ZoFreX


1 Answers

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.

like image 164
Brian Agnew Avatar answered Sep 21 '22 11:09

Brian Agnew