Post Image

TIP: Animate Line Under Button

I got a question the other day about a UI design for an upcoming Codename One app. In this UI the title floated on top of the content as the content scrolled past and tabs were a part of the title area in the style of material design.
Our tabs component predated material design by many years and wasn't designed for this sort of UI. When you scroll out of a tab it scrolls out. Using it for this sort of UI doesn't make much sense. The solution was to use a custom title area with two toggle radio buttons representing each tab with a line below to indicate the selected button.

Read More
Post Image

TIP: Edit the Docs for Fun and Profit

On occasion I answer a question on stackoverflow, the discussion forum or elsewhere and I get a response of the form of: "this wasn't clear from the docs". We improved the docs but befitting a huge project run by engineers without a technical writer in sight this is a bit of a problem... The thing is that this is a problem you can fix regardless of your level in engineering or in English.

Read More
Post Image

TIP: Using Git for Codename One Projects

I wrote in the past about importing a Codename One demo from github but I left the whole working with git as an open subject. Mostly because I considered it a bit out of scope for the discussion. I have a section in the free online course about the anatomy of a Codename One application which I completely forgot to upload until I wrote this!

Read More
Post Image

TIP: Don't Put Text Fields in Dialogs

Text input is a very special case. Besides mixing the native and Java code we also need to deal with the appearance of the virtual keyboard which doesn't act consistently across platforms. This creates many complex edge cases that are just as problematic on native OS platforms as they are in Codename One.

Read More
Post Image

TIP: Don't Ask Again

One of my favorite things about Mac OS is something subtle that took me a while to notice: it doesn't ask stupid questions. If you delete a file on a Mac it goes to the trashcan immediately, no question. Even though other OS's copied the trashcan concept they didn't embrace it in the same way, most of them still ask whether you are sure about this action even though the action is reversible.

Read More
Post Image

TIP: Understand Image Masking Performance

Image masking allows us to adapt an image which we acquired from an external source to fit our design e.g. if we want to show an image cropped to a circle we could apply a mask to it in order to get an intelligent crop. This is a very powerful tool as a designer can supply a hardcoded mask image and build some pretty complex shapes that include an alpha channel as well (making it superior to shape clipping).

Read More
Post Image

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.

Read More
Post Image

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.

Read More
Post Image

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.

Read More
Post Image

TIP: Use the Native EDT

The bootcamp is winding down and I'm finally back to our usual scheduled posts. I'd like to open with a common practice that isn't nearly documented enough: use the native main/EDT threads. Our EDT serves many purposes but one of it's biggest roles is portability. By having an EDT we get consistent behavior across platforms.

Read More
Post Image

TIP: Track Designer & GUIBuilder Issues

We are on a mid-bootcamp break so the blog is back to life during this time (and there is so much to write!), more on that tomorrow but for now I'd like to write about fixing & tracking issues with the designer (resource editor) and the GUI builder.

Read More
Post Image

TIP: When Shouldn't I Use Codename One

Bootcamp registration closed well and we are currently in the pre-course (more on that in another post) and already the Facebook group of the bootcamp is seeing decent activity. Being as busy as I am I thought I'd lift a question that was asked there to headline this post: "When shouldn't I use Codename One?".

Read More
Post Image

TIP: Select Table Row

Before we go into the tip I'd like to start with an apology to all the people I didn't get back to. Earlier today I sent an email asking for help with the upcoming Codename One bootcamp. The anticipation and resulting email flood took me totally off-guard as I expected a couple of dozen responses in the best case scenario and got much more...
I started answering as fast as I could and getting back to people I already answered in the back and forth but quickly this became untenable and I'm seeing my backlog pile growing. Chen and others around here tried to help but I prefer to do this personally as I'd like the feedback to sink into my brain not as an afterthought as it is very valuable!

Read More
Post Image

TIP: Lightweight Rich Text View

A very common request is support for rich text in Codename One, this is hard to do in a generic/performant cross platform way but can be done as I explained in my answer here. This is pretty common though so it might be worth it doing this in a generic way.

Read More
Post Image

TIP: Use iOS CocoaPods Dependencies in Native Code

Last week I talked about using gradle dependencies to build native code, this week I'll talk about the iOS equivalent: CocoaPods. We've discussed CocoaPods before but this bares repeating especially in the context of a specific cn1lib like intercom.

Read More
Post Image

TIP: Use Android Gradle Dependencies in Native Code

Integrating a native OS library isn't hard but it sometimes requires some juggling. Most instructions target developers working with xcode or Android Studio & you need to twist your head around them. In Android the steps for integration in most modern libraries include a gradle dependency.

Read More
Post Image

TIP: Use Tethering to Simulate Slow Network Connections

I recently had to debug some code on Android Studio and was reminded how awful that IDE really is. IntelliJ is a pretty good IDE but Android Studio is remarkably slow even for trivial projects... One of the things that make it slow (besides RAM usage) is the approach of downloading everything it needs dynamically.

Read More
Post Image

TIP: Customize Tabs Behavior

The Tabs component isn't our first attempt at the the multi-tab UI and as such we made a lot of changes to the logic to facilitate a level of flexibility that can answer most use cases e.g. Tabs that can be closed with an X on the top right section or span multiple rows.

Read More
Post Image

TIP: Nest cn1libs Cross Dependencies

On occasion developers ask us for cn1lib dependencies, e.g. allowing one cn1lib to use functionality in another cn1lib. This isn't something we rolled into the cn1lib infrastructure because we strongly believe in simplicity. Dependency management solutions become fragile once nesting sets in and often mask over-engineering which is really dangerous for a tool that depends on small footprint.

Read More
Post Image

TIP: Setup a Codename One Project from Git

Opening a demo or sample code from GIT is relatively easy if you are an experienced Codename One developer but for a lot of newer developers for whom samples are often more crucial this can be challenging. One of our solutions was placing the demos in the Codename One new project menu but that's probably not enough.

Read More
Post Image

TIP: Table to Box

One of the most painful aspects in any mobile app is input, besides the difficulty of viewing the details on a tiny cramped screen the input via the virtual keyboard is nowhere near the input comfort of a full fledged computer or even a tablet.

Read More
Post Image

TIP: Search the Website

A frequent complaint we get is the lack of a search feature on the site and we get that. It's frustrating to us too. We'd like to add it but are still looking at the "right way" to do it which I'll discuss at more length below but for now I'd like to discuss a couple of relatively simple workarounds.

Read More
Post Image

TIP: Avoid 2D Arrays

In the first betas of Codename One we had a lot of bugs related to 2D arrays due to XMLVM. We no longer use XMLVM but the recommendation to avoid 2D arrays remains. We still use them in some occasions e.g. in the creation of a DefaultTableModel but the implementation discards them in favor of an ArrayList internally.

Read More
Post Image

TIP: Cross Platform Update Available Strategy

One of the nice things in mobile development vs. desktop is the fact that updates are seamless. We supposedly don't need to worry about them and most newer OS's turn them on by default. This keeps are users with the latest version which is important, e.g. if we fixed a crucial bug or added a new monetization option...

Read More
Post Image

TIP: How to Ask a Question

I deal with a lot of questions every day and unfortunately most of them are phrased in a way that forces me to guess. There are some guidelines on how to ask a question but I think they are mostly pretty bad. Asking a question "correctly" helps you tremendously both in getting a correct answer faster and also in solving your own question. Following these three rules will significantly improve your questions

Read More
Post Image

TIP: Get Stack State (trace) from Java Processes

One of the most frustrating things that can happen to developers is when you manage to reproduce a rare bug but you are not in the debugger when you did that. My kingdom for a stack trace...
But this is also pretty frustrating when you work on a tool like Codename One's designer or GUIBuilder and they suddenly freeze with no visible error. How do you provide a viable bug report for that?

Read More
Post Image

TIP: Create Square Icons

This is inspired by this post that covers the process of creating different icons for different OS builds. But here I'd like to discuss the lowest common denominator and how we got it wrong!

Read More
Post Image

TIP: Border Layout can Adapt to Orientation

Some designs don't work well in landscape/portrait mode and we need to adapt them to fit the orientation of the device e.g. when we have a large graphic element (icon etc.) on top/below and we no longer have room for that element.

Read More
Post Image

Using the Designers Command Line Options

Codename One's resource files contain a lot of details but it's sometimes hard to add elements into the resource file automatically. Recently I wanted to add a better way to add images directly in the new GUI builder. I considered several options and eventually decided to operate the designer tool automatically to do the "heavy lifting".

Read More
Post Image

TIP: Don't use File - Save As in Photoshop, only use Export

This isn't a programming tip, but since we discussed photoshop quite a few times before it's probably an important subject. Especially because we made this exact mistake in those tutorials and I've spent the better part of the day tracking this with no result...

Read More
Post Image

TIP: Don't Use ComboBox

We previously discussed the problems with List and somewhat neglected ComboBox which is a subclass of List. ComboBox has the dubious "honor" of deriving most of the problems List has and adding a slew of its own problems such as two separate renderers, different behaviors between OS's etc.

Read More
Post Image

Tip: Disable Google Play Services

Google Play Services is a proprietary set of tools that Google licenses to vendors under limited conditions. In recent years more and more features go into Google Play Services making it harder to build an app without it.

Read More
Post Image

Codapps.io is back Java on Mobile from Scratch

We've discussed codapps.io before, it's a MOOC (online course) that allows you to learn Java programming and uses mobile/Codename One as its vehicle. Our current documentation and tutorials can be quite intimidating to a person who is a complete Java newbie so this course is quite helpful in bridging that gap.

Read More
Post Image

Rating Widget

The two key factors to improve any product are: get help from your biggest fans and learn from your detractors. Obviously there is a lot of nuance to that wide reaching advice...
Rating widgets embody this advice. They prompt a user for a rating. If it's good we ask him to review the app in the appstore and thus bring more users. If it's bad we ask him to tell us why!

Read More
Post Image

3 Image Tools for App Marketing

Every now and again developers ask us how we do the graphics for our posts/promotions and up until recently the answer was "photoshop". While knowing photoshop is still very worthwhile we still like these 3 tools that provide great shortcuts to creating both screenshots and art.

Read More
Post Image

How I Chose my Replacement for Parse.com Part 2

You probably recently received the “Next Steps from the Parse Team” newsletter in your inbox in which you were urged to take immediate action as it pertains to migrating your Parse.com hosted apps.

Read More
Post Image

Open Source cn1libs

When we initially designed the cn1lib file format we looked at jar files as a starting point. We wanted a way to distribute binary libraries that support the native code access, restrictions and ideally code completion.

Read More
Post Image

How I Chose my Replacement for Parse.com

When I first read the announcement that Parse.com would shut down on January 28th 2017, I went from disbelief (it’s probably an early April fool’s joke) to rage (how could they do that?!) to sadness (oh no! it was a great service) and finally to utter confusion (where do I go from here and what do I do with my apps - parse4cn1, two MVPs for clients and an upcoming rewrite of Medex for which I was planning to use Parse.com as backend?). A few months down the line, a lot has happened such as the release of the open source Parse Server (yay!) and subsequently the Parse Dashboard. However, I still had to decide what do with my apps and I guess you have to as well.

Read More
Post Image

Keep Track of Codename One Changes & Duplicates

One of my pet peeves when we switched to github was that email notifications never worked for me. For most repositories I had to setup my own account just to get emails. I'm guessing that this is a common problem for those of us who are used to emails notifying us of changes.

Read More
Post Image

Sticky Headers

Sticky headers was one of the first big requests we said no to. Back in the day a lot of people asked for it but we always shot it down because it was too hard to implement on top of our Swing inspired lists. This predated our Container improvement, InfiniteContainer and InfiniteScrollAdapter.

Read More
Post Image

NetBeans Plugin Update Center

The NetBeans plugins.netbeans.org site has been down for another weekend and has been down again today. This isn't ideal as we like the convenience the official plugin center affords in our update process. However, this blocks installs and updates of our plugin most of which originate from NetBeans.

Read More
Post Image

Clarifying our Support

For years we treated support with a "we'll meet our developers where they are" attitude which is problematic now that we have more than 6 free support channels!

Notice that we didn't include the email/phone support for pro/enterprise users in the list of 6 channels...

Read More
Post Image

Default & Static Methods In Interfaces

In our original Java 8 support announcement post we specifically mentioned the lack of streams but completely missed the fact that default/static native interfaces didn't work. This is now fixed thanks to an alert community member who pointed that out.

Read More
Post Image

Icon Fonts & Old VM Swan Song

While multi-image's go a long way in making your app scalable to various devices, scalable images can be even more convenient. The SVG standard never took off though, its too complex to support in an efficient way on the devices and so its relegated to web applications and even those don't make heavy use of it due to its complexity.
However, icon fonts have gained a lot of popularity in recent years and we used them in the past in Codename One e.g. in the photo demo.

Read More
Post Image

Shrinking Sizes & Optimizing

Our build servers are really fast, even if your laptop is relatively slow our iOS build servers are powerful machines equipped with fast SSD's and they generate a full clean build of a typical app (with screenshots etc.) in a couple of minutes!
So the real source of delay when building an app is size, it both slows the build but most of all it slows your upload process (upload is typically much slower than download). Reducing the size of your app will make it faster in runtime as well, e.g. if you have too many redundant resources you might be running into too many GC cycles slowing down execution. In this post we provide some tips to shrink your app size.

Read More
Post Image

Flat Themes, DPI's & Static Initializers

With the release of 3.0 we were overwhelmed with a lot of last minute features and improvements. It seems that we neglected to mention a lot of features that made it into the final 3.0 product.
One of the nicest new features is a set of new flat themes with various colors in the designer and the project wizard. We found that a lot of developers prefer themes with more control over the look, themes that look more similar across platform yet have a more modern "flat" feel.

Read More
Post Image

Gallery, Icons & Updates

Now that the new website is live we are down to standard business again beyond just the typical bug fixes. Chen just updated the gallery support to include the ability to pick a video file and not just an image file...

Read More