Open URL after click on hyperlink stringItem
Hi,
I'm using NetBeans 5 and I have stringItem label with the HYPERLINK Appearance set on it. But I have no idea on how to open a web address when the user clicks the element.
The lack of samples and documentation from sun.com is astonishing, so any info will be really appreciated.
[302 byte] By [
Inuya5haa] at [2007-11-26 20:32:32]

# 1
taken from UIDemo examples of SUN WTK
/**
* Signals the MIDlet to start and enter the Active state.
*/
protected void startApp() {
display = Display.getDisplay(this);
mainForm = new Form("String Item Demo");
mainForm.append("This is a simple label");
StringItem item = new StringItem("This is a StringItem label: ",
"This is the StringItems text");
mainForm.append(item);
item = new StringItem("Short label: ", "text");
mainForm.append(item);
item = new StringItem("Hyper-Link ", "hyperlink", Item.HYPERLINK);
item.setDefaultCommand(CMD_GO);
item.setItemCommandListener(this);
mainForm.append(item);
item = new StringItem("Button ", "Button", Item.BUTTON);
item.setDefaultCommand(CMD_PRESS);
item.setItemCommandListener(this);
mainForm.append(item);
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}
public void commandAction(Command c, Item item) {
if (c == CMD_GO) {
String text = "Go to the URL...";
Alert a = new Alert("URL", text, null, AlertType.INFO);
display.setCurrent(a);
} ....
}
as you can see, a Command is associated to the StringItem...
> The lack of samples and documentation from sun.com is astonishing
i'm sorry but YOU are astonishing. there is plenty of documentation on sun.com...
just search on the web