Java – is there a good way to abstract the GUI, so you can use SWT or swing?

I am writing an application with SWT GUI, but I hope the end user can choose between SWT and swing I've tried to abstract GUI details before different layers of the program, but I'm never satisfied with the results Is there an agreed or good way to do this?

Solution

Unfortunately, I don't believe in a Toolkit - independent API or something like that

So maybe it's worth looking at the model view controller mode You need to abstract as many functions as possible from the GUI into the controller so that the GUI components are thin and dedicated to the specific window toolkit you choose

This will allow you to insert swing views instead of GWT views (and vice versa) with minimal duplication of code

Also note that this makes testing easier because you fold as many tests into the controller or model as possible

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>