Saad Attieh
Saad Attieh

Reputation: 1486

using codename one with Eclipse

I have a current java application that I would like to run on an iPhone. This is just for interest and therefore I do not mind if the GUI is a little off so I hope to do this with as little steps as possible.

I have installed the codename one plugin into eclipse but am not sure where to go from here.

What I have done:

I created a new project of type codename one opened the source folder (in Eclipse) and replaced the created files with my already written java files. However I now have errors for every use of a swing component within the files. What can I do?

I was thinking I'm not supposed to remove the files I deleted - they were just generated classes but then I don't know how to merge that with my current java program (it's a chess application btw).

Also, all my java files are in a package called chess - is this a problem?

Sorry I am just not sure where to go from here - can't find anything useful on the internet. All I need is the simplest way to take my java code and converted to c (Obs) and a way of transferring that on to my iPhone to run.

Thanks in advance for any advice. PS I just noticed I think some imports belonging to codename are missing from the file. Is there a way I can insert all the required imports automatically? PPS OK a couple imports eclipse has decided to insert have removed errors. These are ones such as

import com.codename1.ui.events.ActionEvent;

What are the imports required for JFrame, JChechkBox, JButton, JLabel, etc? Is there a ...*; directory that I can import to acquire the necessary packages?

Thank you again!

Upvotes: 2

Views: 1778

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

Codename One doesn't support Swing. Swing has many desktop level assumptions. You will need to rewrite the Swing code to use the Codename One API and possibly other uses of Java features such as reflection which is also unsupported (to keep the code size small).

Its possibly not a good idea to remove the code we generated since a main method isn't the right way to build a mobile app. You need the lifecycle class and the theme.

The Codename One UI API is very similar to Swing so porting should be trivial in some cases but it is work and some things are just different.

Upvotes: 6

Related Questions