This code works for me in the constructor of my jframe, it prints me an image in a label. Now I have a checkbox and when pressed I want to put the image for a second because of the timer but I mark error the repaint () method asks me the Netbeans create the method within the actionlistener, I do not know how to fix it. here my code in the action performed of the checkbox:
private void simulacionActionPerformed(java.awt.event.ActionEvent evt) {
if(simulacion.isSelected()){
t = new Timer(1000,new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
ImageIcon imagen0 = new ImageIcon("src/imagenesmedidor/menora50.jpg");
Icon icono0 = new ImageIcon(imagen0.getImage().getScaledInstance(medidor.getWidth(),medidor.getHeight(), Image.SCALE_DEFAULT));
medidor.setIcon(icono0);
this.repaint();
}
});
}