I have a finished Swing Application and I am thinking about porting it to android. The thing is, I dont know much about android, but I know that it does not support Swing. What a bummer.
What would you recommend I do?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I have a finished Swing Application and I am thinking about porting it to android. The thing is, I dont know much about android, but I know that it does not support Swing. What a bummer.
What would you recommend I do?
Android GUI is very different from Swing.
Study the tutorials. Here are some links:What would you recommend I do?
http://developer.android.com/index.html
http://developer.android.com/guide/c...damentals.html
I ported a couple of very simple desktop applications to Android as a start to learning Android. I'd recommend starting simple and advance as you learn.
If you don't understand my answer, don't ignore it, ask a question.
So you say I should port everything by hand.
Is there no alternative which is less error prone and more handy?
Not sure what you mean by "by hand". I don't know that there is a "converter" program to do it.
Most of the GUI design and interfaces need to be completely redone.
A desktop window has mouse and keyboard events. Android has that plus many different "touch" and other sense events. I'm working on an app now that needs to be sensitive to the device's orientation and to know whether the screen is on or off.
Many different ways for the user to interace with the app. It's a Whole new world for me.
If you don't understand my answer, don't ignore it, ask a question.
I mean I will have to learn the android API and start all over from scratch to create the entire GUI-code all over again.
I already have a finished and working version, it would be really nice if I could just keep using that in some way, but when its not possible then its not possible.
Its a real bummer though. I hoped java would be a little bit "more" cross platform if you know what I mean.
Yes, that is pretty much true.I mean I will have to learn the android API and start all over from scratch to create the entire GUI-code all over again.
It's mostly the GUI that's new. For the apps I ported over, most of the non-GUI code copied and pasted into the Android project without any problems.
If you don't understand my answer, don't ignore it, ask a question.
Well, that sucks, I really hoped there woud be another way.
The GUI needs to be created from scratch, but you can port the operational code by refactoring your Swing Application.
To do this refactoring:
1. Create a new project (let's call it: "Core")
2. Move all operational code from your Swing project to your Core project and refactor the code so the Core project is NOT dependent on the Swing project (Core should have no reference to Swing whatsoever)
3. Add the Core project to your Swing project's dependencies and connect the loose ends back up (your Swing Application should now work exactly like it did before refactoring)
4. Create the Android GUI in your Android project
5. Add the Core project to your Android project's dependencies and connect up the loose ends (your Android project should now be functional)
This approach allows you to maintain a single code base (Core) for the operational code for both your Android and Swing applications. A huge benefit to this comes when debugging. If you have a bug in your Android app, and you cannot reproduce it in your Swing application, this would mean that the bug is located in your Android project, not your operation code (Core). If you have a bug in your Android app and you can reproduce it in your Swing application, this most likely means that the bug is located in your Core project. You can fix the bug once in your Core project, and you can then immediately release the fix for both the Android and Swing applications. A shared codebase means you only have to fix the bug in one place.
NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:
When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.
Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/
ChristopherLowe (July 16th, 2014)
Everything Norm said is true. If you're looking for an automagic way to convert Swing code to Android code, you're out of luck- as you should be, since Android is a completely different environment with different inputs.
That being said, JavaFX supposedly deploys to both desktop and Android. I've never tried it myself though.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Well, thank you all for the responses.
The real problem is just, that the GUI was about 75% (or more) of all the work put into the project. The core functionality is incredibly simple. The thing is that the visualization is key as well as giving the user an easy and comfortable way of manipulating the underlying data.
The Swing part is quite complicated with all kinds of custom Renderers and Models and about every kind of Swing component you can think of.
I really was hoping there was some kind of standard way of doing it. After all, java is supposed to be cross platform and since Swing is part of the Standard Edition I just hoped this principle would apply to swing as well.
Exactly: Swing is part of Java SE. Android isn't Java SE, it just "borrows" a lot of stuff from it (hence the lawsuits between Java and Google). It does not borrow Swing, since the graphics are very different on Android.
More info here: http://en.wikipedia.org/wiki/Compari...nd_Android_API
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Yeah, I read that already, thats why I asked here. Its a real bummer, I was very disappointed when I found out they did not include the complete SE.
In the long run, it makes a lot of sense. Swing is on its way out, and Android needs to keep up with the latest technological innovations. Swing probably isn't the way to do that.
I've seen JavaFX working on Android, so it's at least possible. But really, if you want to be a good Android programmer, you should learn "the Android way" of doing things. It's really not that bad once you get used to it.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
I dont want to be a good android developer. I dont have an android device, I would not even be able to test it, but some of my users asked if the port would be possible so I wanted to do some research.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
I've heard thats not very accurate, people told me that the simulation is not quite the same as an actual phone and some programs run on one but not the on the other.
But yes, eventually I think I will have to get used to it. Probably have to buy an Android just for work.
The emulators are accurate enough. They are slower (normally), but functionally okay. You can configure the emulators to emulate specific devices to test with, so there is a lot to work with there without getting actual hardware devices. A program may run on some devices, and won't run on others. It depends on the Android version the phone uses and the Android version the program was built with.
NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:
When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.
Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/
Thank you for clarification.
If you have a specific phone you are making the program for (or a specific group of phones), find out what version of Android they run, and build your program with it. If you do that, there should be no reason (apart from bugs) that the program should not run properly on the phone.
NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:
When asking for help, please follow these guidelines to receive better and more prompt help:
1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
2. Give full details of errors and provide us with as much information about the situation as possible.
3. Give us an example of what the output should look like when done correctly.
Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/