The following J2ME code extract shows how a listener might use getString( ) to retrieve the last value that the user entered as a String:


public void itemStateChanged(Item item) {

  if (item instanceof TextField) {
    System.out.println("Text field content: <" +
    ((TextField)item).getString( ) + ">");
  }

}