I’m having problems updating ( or refreshing) an Icon from button after closing a modal dialog. The image is basically overwritten by some actions of JDialog.
This is my code:
conf = new Configurar(this, true,control);
conf.setVisible(true); // Open dialog
System.out.println("Cerrado"); // Check if is closed (debug)
String logo =(String)config.get("logo"); // get path from image
File newIcon =new File(logo); // Desesperate try
ImageIcon img = new ImageIcon(newIcon.getAbsolutePath());
btn_main_image.setIcon(img);
this.update(btn_main_image.getGraphics());
btn_main_image.updateUI(); // First Try
this.repaint(); // Second Try
The first time it works fine, but when I open the dialog and change the image remains the same.
1 Answer