Inner Classes

Regular Inner Classes:


The action listener for a TextField is fired only when you press the "enter" key. The getActionCommand() method simply returns a String which in the case of textfields is the contents of the textfield.
Anonymous Inner Classes:


You will notice that there is no name given to the ItemListener class. Normally you would see something like:

  b.addItemListener(new IL());

Then somewhere else you'd see a class definition which begins like:

  class IL implements ItemListener{

But using inner classes all this gets skipped or abbreviated. You will notice that the parenthesis which is opened in the addItemListener line isn't closed until thirteen lines later. The ItemListener interface contains only one method: itemStateChanged().