Deixei um exemplo funcional no seu outro tópico: http://www.guj.com.br/posts/list/221679.java#1134695