In this example, we'll define and instantiate a
textField object and several label objects. | |
We'll use init and the default layout
manager (Form) to place these objects on the display. | |
Finally, once someone has keyed in some text, any text that is highlighted (ie. selected) will be displayed in the message2 label thanks to the keyUp event |
public boolean keyUp(Event e, int keyValue)
{
message2.setText(blankTxt.getSelectedText());
return super.keyUp(e, keyValue);
// pass the event onto other event handlers that might "want" it
}
} /* end of applet */
Note, if you try this applet out, remember to
change the applet name to "ShowSelectedText.class" in the .htm file with the code
parameter - |

![]()
Created &
Maintained by DrB - Comments welcome.
Last edited on Friday, July 30, 2004