How to convert a java swing application to work on android
So I built a program in Java using swing for the interface and i didn't realize how difficult it would be to convert it to be used as an android application. Is there any way for me to easily convert or rebuilt the program to be sold in the android market place? If not开发者_C百科 can anyone point me toward any resources to help build a android.
I did the same thing awhile back. Although there is no program out there that I know of to convert it directly. The Java code and the android code are very similar. Since android doesn't use swing's UI it uses XML
based UI. once you get the UI functions of the android app down your Java code can be easily imported.
I am working on converting my Java app into an android app now. Most of my classes imported with no problem.
AjaxSwing allows to convert Swing applications and use them directly on android or ipad, see http://www.creamtec.com/products/ajaxswing/solutions/java_swing_ui_on_ipad.html
What I would do is that I would build the UI in XML, then I give the items an ID and reference to it in Java, and then I'll trigger everything by button clicks so what one button does in your swing layout does the same on android. You can't copy/paste it.
swing UI was meant for desktops and pc's but for android you have to use Xml then you can keep your java codes as they are in the various activities then use your event handling skills to trigger them
Open the project's properties
Select Java Build Path
Select Libraries tab
From there you can Add External Jars and you can use swing layout
精彩评论