Porting AWT graphics code to Android

appengine-awt is a pure java implementation of the java.awt and javax.imageio packages for use in the Google AppEngine environment.

https://github.com/witwall/appengine-awt

SwingWT is a 100% pure Java library which aims to be a free implementation of Swing and AWT. Unlike Swing, it drives native peer widgets for your platform from SWT.

https://github.com/witwall/SwingWT


The android platform supports a small subset of awt. By small, I mean it supports awt fonts. Going from java swing (are you really just using awt as a standalone UI?) to Android is going to be a shock to the system. One defines Android's UI in XML resource files, and those resources are loaded into Activity classes which represents a logical unit of the application. Canvas' replace Graphics2D objects, and they have somewhat different functionality.The Android UI system seeks to avoid absolute positioning, which is common in java UI's. And there is so much more to consider for Android, like varying screen sizes and differences in resolution. Neither of which were much of a issue for Java SE. To answer your question: you have your work cut out for you and you will have to start much of your coding from scratch.

I'm not sure what 'drawing code' means, but in my case, I have a large amount of animation code that is displayed via awt shapes. This is reproducable on android as there are graphics.drawable.shapes objects, and one can display primitive shapes by doing something like canvas.drawCircle(x,y,z,h) (remind you of something?). But when I ported it, it was difficulty and felt like I was cortorting the android to do something it really didn't want to, and wasn't intended to do. It's hard to answer your question exactly given the vagueness of it.


I don't think you can port AWT to Android. I mean, it's Java SE vs a subset of it (or an updated Java ME with steroids, as you prefer).

There are though, some UI classes for Java ME that work perfectly on Android. Personally I like LWUIT but it's not the only one.