If a MIDlet has several screens, it can choose to create a single listener class for each, or it can save even that overhead by subclassing the screen class to implement CommandListener, as follows:

public class MyTextBox extends TextBox implements CommandListener {

  public MyTextBox(String title, String text, int maxSize,

    int constraints) {
    super(title, text, maxSize, constraints);
    // Add Commands (not shown)


  // Handle command actions
  public void commandAction(Command c, Displayable d) {
    // Code not shown