There was much left unsaid about the template UI that I did earlier in the week. It was doable & reasonably easy but I still had some pitfalls. I was able to circumvent them easily but I’m not so sure these would have been easy for other developers out there. As a result we decided to simplify some use cases in Codename One as a result.
I chose to separate these to a different post as most of the subjects here will be resolved in the next update, but the template post would probably still be useful when this post becomes history…
Side Menu Opening
The designs to the template UI placed the menu button at the top, we have a special case to allow that but that special case doesn’t deal with the settings placement at the top too. The solution I took was to define the theme constant hideLeftSideMenuBool=true which hides the sidemenu button. I then added my own button with the menu button icon as such:
Another difficulty is in the level of control over the status bar in iOS. iOS apps space their top portion to leave room for the status bar. You can customize that UIID but that means customizing it for all the forms which might not be what I want…
To allow a component and its placeholder to have the same size before I use Container.replace to fade in the component. So I added:
Which saves writing the same line twice…
Now you might be thinking, why not use notesPlaceholder.setPreferredSize(notesLabel.getPreferredSize()).
This is how we used to do things and it does work well for simple cases like this. But what if I want to replace an entry not with a placeholder but rather with an entry that might be bigger on an axis?
In that case I’ll need to check which component is bigger in each axis and apply the right dimension which isn’t a problem with the original code.
I ignored the fact that setPreferredSize is deprecated because I don’t think that should be the reason
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.