Latest posts from Codename One.
Blog

Test Recorder and Toolbar
One of the key takeaways I have from the bootcamp is the need to work on TDD in Codename One. We had a test framework and test recording framework for years, but it wasn’t picked up by many developers and as such it stagnated. As we launched the Toolbar API we didn’t even check that framework and some basic stuff stopped working. This was something several attendants in the bootcamp mentioned as important as well as a couple of enterprise customers so I knew we had to revisit this feature. With this weeks update commands should be handled correctly even with a toolbar and features such as “wait for title” should work for a form with a Toolbar. I’d still recommend using setName() for any component you want to test as this will make the generated code far clearer to the human observer when you record a test. ...

TIP: Handle EDT Errors
Tracking & logging errors is crucial for a stable application. There are several tools we offer in Codename One both in the seamless level (crash protection) and in the lower level inner workings of Codename One. I’ll try to explain both and how they interact. When you create a new Codename One application you might notice this line of code: Log.bindCrashProtection(true); This code binds the pro crash protection feature that will implicitly send you an email whenever the app crashes or has an exception. This email will include the stack trace and other output you wrote to the console using Log.p(). ...

Tutorial – Layout Basics
Layouts are one of the hardest subjects to grasp in Codename One, there is a lot of nuance in getting layouts “right”. Since the subject is so vast and complex this video only scratches the surface and is still relatively long for an introductory video. It’s crucial to go thru this material though if you are not familiar with layouts or find them confusing. Ideally, I’ll follow up with a more “pragmatic” video of layouts that will build on top of this video to explain how common layouts are achieved. ...

My iOS Build Won't Install
Recently I sent a build and had an issue installing it. It was late at night and I just forgot to add the build hint ios.debug.archs=armv7 for installation on the 3rd gen iPad I was testing with. So we can all trip over basic mistakes when it comes to iOS installs. So for your convenience I made a list of common pitfalls you might run into if your iOS build won’t install on your device. ...

Sidemenu On Top
This feature is still undergoing development but I wanted to share the progress here so we can start getting bug reports and suggestions. One of the frequent requests for the side menu UI is to provide a way for it to render on top of the UI instead of shift the UI. The old side menu was written when the facebook app was the chief application that used that UI paradigm so it was built to match that approach. ...

TIP: Auto Complete Renderer
I’m a bit conflicted about this tip. The AutoCompleteTextField is a problematic class that is in dire need of a rewrite. When we created it we still didn’t accept that lists “need to go”. It also predated features like the InteractionDialog which would have made this component much easier to use. Check out a live preview of the demo on the right here thanks to our JavaScript port! However, we have other priorities and rewriting AutoCompleteTextField isn’t even in the top 100… So we need to still live with it and with the renderer that it exposes. ...

Tutorial – Create a Gorgeous Sidemenu
One of the biggest challenges facing new Codename One developers is the challenge of creating an elegant looking UI. This isn’t trivial in any tool but we don’t make it easy enough in some cases. In the tutorial below I’m focusing on one of the most important UI elements: the side menu. I chose to use a very simple design so this will be easy to follow, you can easily build on top of this to create highly customized styles. ...

Threadsafe SQLite
One of the main reasons for the thread API I discussed yesterday is a new threadsafe Database API. This new API allows you to wrap your Database instance with a thread that will hide all access to the database and implicitly make it threadsafe by serializing all requests to a single database thread. This also has the side effect of removing the hack of working with sqlite on the EDT which could sometimes cause a stutter in the UI when performing SQL. In fact, that was the chief motivation for this particular enhancement! ...

Easy Thread
Working with threads is usually ranked as one of the least intuitive and painful tasks in programming. This is such an error prone task that some platforms/languages took the route of avoiding threads entirely. I needed to convert some code to work on a separate thread but I still wanted the ability to communicate and transfer data from that thread. This is possible in Java but non-trivial, the thing is that this is relatively easy to do in Codename One with tools such as callSerially I can let arbitrary code run on the EDT. Why not offer that to any random thread? ...

TIP: Listen on All Radios
Using toggle buttons in touch interfaces is very intuitive for many use cases. We implement them via RadioButton or CheckBox to indicate inclusive or exclusive selection. As a result I find myself using RadioButton quite a lot and ran into an ommission that frankly should have been there from day 1. Up until now you couldn’t listen to selection on the ButtonGroup only on the RadioButton itself which isn’t as convenient since for pretty much every case you had to bind listeners over and over. With the latest version of Codename One you can bind a listener to the button group directly like this: ...

Questions of the Week 50
I’ve been back from the bootcamp this past week and while I have committed many new changes I’m still taking things relatively easy after the hard work of the bootcamp. This will be the last Q&A Friday segment in the blog. Starting next week I’ll replace this segment with “tutorial of the week” which will focus on publishing/updating a “How do I?” video tutorial on a weekly basis. ...

Fingerprint/TouchID Support
Fingerprint scanners are pretty common in modern hardware both from Apple and some Android vendors. The problem is that the iOS and Android API’s for accessing them are a world apart. However, it’s possible to find some low level common ground which is exactly what our cn1lib for fingerprint scanning accomplished. This is a very basic API that just validates the user as the owner of the device, it’s useful to lock off portions of the application from a 3rd party using code such as: ...