So I’m trying to make an app for my Iphone. Why? Why not.
I researched all the various methods, and decided, based on reviews and comparisons from other sites, to go with Codename One. Great looking site, active forums, it seems like the real deal. I’m going to have to deal with crashes or buggy features or something that just plain doesn’t work. It even has a tutorial for beginners. So here’s my first five minutes. May others find it informative.
You have to use a supported code editor. It doesn’t come with its own, so you have to download netbeans or eclipse as well. I already had netbeans, so I just had to download codeone and install it as a netbeans plugin. It worked, until I tried to create a new project. Nothing. It say its successful, but nothing happens.
Solution: reinstall netbeans. My existing plugins caused codename one to not work.
Now I have a new project, annnddd… now what? Codename one creates a bunch of files, and they show in a list at the side, but what are you supposed to do? Turns out you are supposed to find the file named “theme.res” and double click on that.
This brings up the GUI editor in a separate process. This looked all right. A big ‘add a new GUI element’ seems to create a form, which you can see on the left of your screen, and a separate panel lets you drag and drop components (buttons, checkboxes) onto it. There is a default form called main. Good. I add a button that does nothing, go back to the main screen, and tried to run the program. A simulator pops up but my changes did not appear. Ok….. I try again. This time click save. There we go. My new button appears as expected. So far so good.
Now how to get at the code for the button? I’m looking, I’m clicking, I’m looking – finally I find it at the bottom of the file statemachine.java. But oh great, there is a warning at the top of the file saying “Do not modify”. So what do I do now? I click around, searching, searching – I find a properties tab headed ‘events’. I click on “Action Event”, a ‘choose file’ dialogue pops up, I assume its asking for the file with the code, I click the statemachine.java, aaaaannnddd… Error. Not a valid application. Crap. I’m stuck. Time to read the documentation.
The in-application help files are useless, but that’s normal. I try online. “Hey look, a hello world tutorial!” Right there on the codebase one site. How thoughtful. So I’m reading, I’m reading, events, events, looking for events, and I read:
Binding Events To The Source Is Trivial And You Can Invoke The Codename One API To Do Anything
But they don’t tell you how to do it! The closest thing I can find is Now we can edit the generated GUI and makes changes to the screens within the GUI builder. We can bind an action event to the button and go to the code to show a dialog.
“Screw it” I say, I’m going to edit the codenamebase file, the one that told me not to edit it. I stick in a basic dialogue Dialog.show(“Hello”, “Hi There”, “OK”, null);, save, click run, aaaannnddd…. YES! It works! A dialogue pops up when I click the button in the simulator.
And thats my first five, or maybe fifteen, minutes with codename one.
I shall continue to use codename one.