J2ME Polish 2.0 Beta 3: ScreenInfo Revisited

March 16, 2007

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).

In my current application, I’m using it a bit differently than I did before, combining it with a Timer to remove the ScreenInfo element after a specified amount of time.

As before, add the corresponding variable declaration to your build.xml file:

<variable name=”polish.ScreenInfo.enable” value=”true” />

You can also style this element in polish.css by using the “screeninfo” predefined style.

In the code sample below, I’m using images and determining margins at runtime, so I’m not utilizing this element, but it’s a quick way to add default styling and positioning.

screeninfo {
margin-top: 10
margin-left: 10;
}

A sample class file is below. In my implementation, I query for the canvas height and width during start-up (and I’d recommend you do something similar), but below is a quick and dirty way to accomplish roughly the same thing. This example could also be improved by accounting for multiple elements and related details.

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Timer;
import java.util.TimerTask;
import de.enough.polish.ui.ScreenInfo;

public class MyMidlet extends MIDlet {
public Display display;
private List mainMenu;
private Timer timer;

public MyMidlet() {
//your constructor code here
}

public void startApp() { }
public void pauseApp() { }
public void destroyApp(boolean unconditional) { }
public static void quitApp() { }

public void showScreenInfo(int icon, long timeout) {
String imagePath = null;
switch(icon) {
case 1:
imagePath = “/si_mail.png”;
break;
case 2:
imagePath = “/si_sync.png”;
break;
default:
//
}

ScreenInfo.setImage(loadImage(imagePath));

//#ifdef polish.FullCanvasSize:defined
//#= int width = ${polish.FullCanvasWidth};
//#else
int width = 176;
//#endif

ScreenInfo.setPosition(width-32, 1);
ScreenInfo.setVisible(true);

timer = new Timer();
timer.schedule(new InfoTimer(), timeout);
}

public void removeScreenInfo() {
ScreenInfo.setVisible(false);
}

class InfoTimer extends TimerTask {
public void run(){
removeScreenInfo();
}
}
}

For more information, you can check out the Polish documentation related to ScreenInfo: Overview | JavaDoc

‘CHI-TONW’ tattoo lawsuit filed | Chicago Tribune

March 2, 2007

I’d love to see a picture of this.

Link: ‘CHI-TONW’ tattoo lawsuit filed | Chicago Tribune.

Lego-inspired Products via the Stylehive

March 1, 2007

legoproducts1.gifIf you’re a fan of Legos, you’ll want to see this stylehive post on five Lego-inspired products, including a coaster set, ice cube trays, magnets, jewelry, and a salt & pepper set. Love the brick!

Full story via stylehive