Crear un selector de avatar
Hola a todos ahora vamos a crear una excelente avatar basado en el codigo del ejemplo del libro Filthy Rich Clients: Developing Animated and Graphical Effects for Desktop Java Applications (The Java Series) (Paperback)

![]()
En el proyecto existe la clase AvatarChooser el cual se la ha modificado para que tu puedas agregar una colección de buferedImage y esta colección se va a presentar en el avatar
private List<BufferedImage>albums;
en el ejemplo se añade la clase Main en la que se añade el avatarChooser a un frame se construye un List de Buffered Images y luego se fija al avatarchosser
public Main() {
initComponents();
List<BufferedImage> album = new ArrayList<BufferedImage>();
album .add(getBufferedImage(new ImageIcon(getClass().getResource(“/avatar/1.jpg”)).getImage()));
album .add(getBufferedImage(new ImageIcon(getClass().getResource(“/avatar/2.jpg”)).getImage()));
album .add(getBufferedImage(new ImageIcon(getClass().getResource(“/avatar/3.jpg”)).getImage()));
album .add(getBufferedImage(new ImageIcon(getClass().getResource(“/avatar/4.jpg”)).getImage()));
album .add(getBufferedImage(new ImageIcon(getClass().getResource(“/avatar/5.jpg”)).getImage()));
avatarChooser1.setAlbums(album);
}
public BufferedImage getBufferedImage(Image image) {
BufferedImage bufferedImage = new BufferedImage(
image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_INT_RGB );
Graphics g = bufferedImage.createGraphics();
g.drawImage(image,0,0,null);
g.dispose();
return( bufferedImage );
}
tenemos el Metodo getBufferedImage(Image image) el cual transforma un objeto tipo Image a BufferedImage
descarga el proyecto
[download#3#image]

![[BlogBookmark]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/blogbookmark.png)
![[Bloglines]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/bloglines.png)
![[del.icio.us]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/digg.png)
![[diigo]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/diigo.png)
![[Facebook]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/facebook.png)
![[Furl]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/furl.png)
![[Google]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/google.png)
![[Kaboodle]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/kaboodle.png)
![[linkaGoGo]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/linkagogo.png)
![[MySpace]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/myspace.png)
![[MyWeb]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/myweb.png)
![[Rojo]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/rojo.png)
![[Spurl]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/spurl.png)
![[ThisNext]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/thisnext.png)
![[Twitter]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/twitter.png)
![[Windows Live]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://edisoncor.mycsistemas.com/wp-content/plugins/bookmarkify/email.png)
Leave a comment