Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/06/2012, 13:19
Avatar de baker1562
baker1562
 
Fecha de Ingreso: marzo-2011
Ubicación: Puntarenas
Mensajes: 261
Antigüedad: 13 años, 2 meses
Puntos: 9
Respuesta: Error al cargar imagen en JPanel usando JRadioButton

Código Javascript:
Ver original
  1. private void jRadioButton1MousePressed(java.awt.event.MouseEvent evt) { * * * * * * * * * * * * * * * * * * * * *
  2. * * * * jButton1.setEnabled(true); //El boton se habilita
  3. * * * * parametro_Figura=1;
  4. * * * * jPanel1.setVisible(true); * //Se establece el JPanel en visible
  5.         jPanel1.removeAll():
  6.         jPanel1.repaint();
  7. * * * * Ruta="cuadrado.gif"; * * * *//ruta de la foto
  8. * * * * CargarImagen imagen=new CargarImagen(165,155,Ruta); *//Creo el objeto donde cargo la foto
  9. * * * * jPanel1.add(imagen); * * //Agrego la foto al JPanel
  10. * * * *
  11. * * } * * * * * * * * * * * * * * * * * * * * *
  12. *
  13. * * private void jRadioButton2MousePressed(java.awt.event.MouseEvent evt) { * * * * * * * * * * * * * * * * * * * * *
  14. * * * * jButton1.setEnabled(true);
  15. * * * * parametro_Figura=2;
  16. * * * * jPanel1.setVisible(true);
  17.         jPanel1.removeAll():
  18.         jPanel1.repaint();
  19. * * * * Ruta="circulo.jpg";
  20. * * * * CargarImagen imagen=new CargarImagen(165,155,Ruta);
  21. * * * * jPanel1.add(imagen);
  22. * * }

Habia que agregar removeAll() y repaint(), para que limpiara y repintara