Fork us on GitHub

ToastBar & Gaussian Blur

We failed miserably at avoiding new features
Post Image

ToastBar & Gaussian Blur

Just last week I wrote that we are making an effort not to add new features and we got foiled by a couple of new features. The main reason for this is paying customers who need to have a feature now. This makes it hard for us to focus completely, but it does keep the lights on here so we can’t really complain.+ To be fair, during this time we were able to almost double the page count of the developer guide from the 3.2 era to 584 pages at this moment and we still have a lot of work ahead of us in that department.


Steve was working with a customer who needed a none obtrusive notification system at the bottom similar to the newer versions of Android’s toast UI. Fabricio already built a native cn1lib for toast messages but because the library is native it isn’t as flexible as we needed.

The new ToastBar API started off as a StatusBar API but we changed that to avoid confusion with the iOS StatusBar. Here is a quick video Steve made showing off the ToastBar.

Gaussian Blur & Dialog Blur

Some effects are very easy to accomplish in Codename One while others not so much. Gaussian blur is one of those none trivial effects that become even harder to achieve when performance is of the essence. Its a really powerful effect that makes the UI standout over the background and should be built in now that its a builtin part of iOS 8+.

We now have two new API’s in Display: gaussianBlurImage & isGaussianBlurSupported.

These API’s let us apply the blur to an arbitrary image which is useful for many things.

One of the chief uses for this is blurring a Dialog. We can apply Gaussian blur to the background of a dialog to highlight the foreground further and produce a very attractive effect. We can use the setDefaultBlurBackgroundRadius to apply this globally, we can use the theme constant dialogBlurRadiusInt to do the same or we can do this on a per Dialog basis using setBlurBackgroundRadius.

Form hi = new Form("Blur Dialog", new BoxLayout(BoxLayout.Y_AXIS));
Button showDialog = new Button("Blur");
showDialog.addActionListener((e) ->"Blur", "Is On....", "OK", null));
Gaussian Blur behind the Dialog
Figure 1. Gaussian Blur behind the Dialog
Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.