With the introduction of the HTML5 <canvas> element, is it possible to embed Swing in GWT?

With the introduction of HTML5 <canvas> is the Swing element theoretically implemented in the Google Web Toolkit (GWT) using the <canvas> for drawing?

I know about trying to transfer source code using Swing calls to GWT calls, but what I follow is a clean port behind the scenes where the Swing application will be compiled under GWT without any changes to the source code.

Is this theoretically possible? What for? Why not?

+4
source share
4 answers

There are some problems.

Local data storage Swing applications can use a disk to store data. Assuming that the local data store available in HTML 5 is working, it will still be difficult to automatically reassign file / disk access for local data store calls.

Multithreading and synchronization Swing applications typically create threads, and this is not possible with GWT. It’s hard to get it right.

Network Access Swing applications can connect to arbitrary network locations that do not work with GWT.

Using Java functions that are not available in the browser Everything that is outside the java kernel is not available, so the automatic port will most likely fail.

Optimize memory and performance Garbage patterns are completely different. How do you optimize optimal download sizes? How can you map multiple rotation screens to use something like code splitting for better performance?

Look and feel Everything said and done, you have to get your hands infected in order to write CSS code in order to get the right look. An automatic port cannot do this.

Given all this, I think that this is not possible for anything other than trivial applications. And for trivial applications, you can also rewrite the code.

+4
source

Theoretically, this is possible, although it will be a non-trivial amount of work and dubious utility. What you need to do is implement the Look and Feel user interface, which defines the UI delegates that generate GWT widgets and on the GWT side, captures mouse and keyboard events on the client and passes them to the Swing event queue.

The problem is that a typical Swing application contains too many input events and widget state updates that will need to move between your browser and backend. This will remove your responsiveness.

+2
source

I would say that this is possible given this technology: http://www.creamtec.com/products/ajaxswing/demos.html

Perhaps AjaxSwing does not yet have a Java2D / HTML5 Canvas (to be honest, I have not tested it). But how far is this when IE9 jumps on board?

+1
source

Short answer: Impossible at the moment. Zero availability!

0
source

Source: https://habr.com/ru/post/1305932/


All Articles