Just use layers(0) instead of getLayer(0).
See
http://docs.geotools.org/latest/userguide/tutorial/map/style.html#creating-a
-style-based-on-the-selection for an updated version of the tutorial. The
old version assumes 2.7 (per pom.xml at the top of the page you linked to).
HTH.
Brad
Dear sir/madam
A problem has encountered when I am running the selectionLab.java file in
the Map Style
tutorial(http://docs.geotools.org/stable/tutorials/map/style.html).
Through consulting the GeoTools API,I find that the JMapFrame class only have
getMapContent() method,no getMapContext()