Java Reference
In-Depth Information
class helloworld {
// It's nice to store command ids as static constants
const int CMD_BACK = 1;
// MenuItems are displayed over the phone's soft buttons,
// usually Back, OK, Options, etc.
MenuItem BACK = new MenuItem(CMD_BACK, "Back");
// The WidSets framework will call createElement() for each script
// element it finds from views being created by createView()
Component createElement(String viewName,
String elementName,
Style style,
Object context) {
// return a simple label with the style defined in widget.xml,
// in this case, "text"
if (elementName.equals("hello")) {
// in order to get the label to align in the middle of the view,
// you'd need to contain it inside a Flow which you'd return here
return new Label(style, &Hello World");
} return null;
} void startWidget() {
// instantiate minimized view in startup
setMinimizedView(createView("viewMini", getStyle("bg")));
} Shell openWidget() {
// instantiate maximized view when user opens this widget
Flow view = createView("viewMaxi", getStyle("bg"));
return new Shell(view);
}
MenuItem getSoftKey(Shell shell, Component focused, int key) {
// return the key we want to display at position=SOFTKEY_BACK
// this is usually the right soft button (RSB); for other key
// positions return null, as we don't want other keys
if (key == SOFTKEY_BACK) {
return BACK;
} return null;
}
void actionPerformed(Shell shell, Component source, int action) {
// when the CMD_BACK event comes in,
// pop the current shell (this widget)
if (action == CMD_BACK)
{
popShell(shell);
}
}
}
 
Search WWH ::




Custom Search