J2ME Polish 1.3: ScreenInfo class
May 24, 2006 · Print This Article
IMPORTANT UPDATE Nov. 23, 2006: The below approach will almost surely fail on your implementations. After this post was written, I learned that the package I was experimenting in had been significantly altered by a colleague to make ScreenInfo work as intended. I don’t recall the specifics of the approach, but will post them if I can find them. If anyone has had any success with an undecorated ScreenInfo, please share.
I’ve been working with the J2ME Polish 1.3 beta over the past week and a half. I had several goals when I began this mini-project, one of the primary goals being to exercise some of the new features in the 1.3 release.In several areas in my sample application, I’ve spawned background threads to do some processing, and I wanted to provide the user with some visual feedback of the processing status. I also wanted to avoid the traditional gauge-based approach, so as to keep these events relegated to the background. GUI programming using MIDP is painful, but J2ME Polish makes a task like this very short work with the new ScreenInfo class.
A word of warning: depending on which beta release I use, and in which screen I use this class, I have varying degrees of success, and I’m at a loss to explain why I can get it to work in some areas, but not in others. Based on what I see on the discussion boards, there are a good number of other problem areas in the beta release, which is to be expected. I wouldn’t let it discourage you from trying out this product.
To use ScreenInfo, first add the corresponding variable declaration to your build.xml file:
<variable name=”polish.ScreenInfo.enable” value=”true” />
Setting this preprocessing variable enables this element for your entire application, but you can use various static methods of the ScreenInfo class to set its visibility and change its appearance (image and/or text). For example, I might choose to display an idle indicator, which changes to an hourglass during background operations; or I may choose to display a connection icon when I’ve established a connection to an external resource, and hide it when the connection is released.
Remember to import the ScreenInfo class:
import de.enough.polish.ui.ScreenInfo;
Image image = null;
try {
image = Image.createImage(”/clock.png”);
} catch (IOException ex) {
//#debug
System.out.println(ex);
}
ScreenInfo.setImage(image);
//w is defined as the screen width in my class
ScreenInfo.setPosition(w-10, 10);
ScreenInfo.setVisible(true);
You can also style this element in polish.css by using the “screeninfo” predefined style:
screeninfo {
font-style: plain;
font-size: small;
font-color: primaryDarkColor;
}
From painful to painfully simple in just a few short steps.
Tags: J2ME, Java ME, J2ME Polish, mobile software, mobile development




I am really trying hard to get this effect, using J2ME Polish 2.0 beta 3, the screen info is not appeating - did you ever figure out what caused it to appear or not appear?
Apologies, Richard. This post really needs updated. I don’t recall the specifics, but I was tinkering in a package created by a colleague, and afterwards learned that she had done a fair amount of work to get this functioning as was intended. I would suggest going to the Polish discussion list to see if anyone there has any further details.
Hi, I just gave it a go, and it works fine. I basically just copied the code from this page in my project and ran it. email me for a copy at jkoorts at gmail com
Hey jkoorts, I plugged this into Polish 2.0 beta 3, and you’re right, works like a charm for me here, without modification of any kind. Go figure. Thanks for pointing it out — it really is a great little feature when it’s working properly!
[...] I thought I’d revisit Polish’s handy ScreenInfo class, as it is working as intended out-of-the-box in the beta 3 release (earlier post here). [...]