I would like to display a% cos_de% larger than normal by interface standard. After some searches I found the Customize JCheckBox icons an example to use, but it does not changes the size of the JCheckBox, but instead replaces its default image with other images that will represent its possible states (mouse over the object, mouse outside the object, marked, unchecked, enabled, disabled, etc.). All right, because I downloaded images, I edited them to fit each situation.
I then created a class called JCheckBox
that extends ACheckBox
to lock the definition of those images to JCheckBox
, where the class is as follows:
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import br.com.alutal.model.Constantes;
public class ACheckBox extends JCheckBox {
private static final long serialVersionUID = 1L;
public ACheckBox() {
super();
this.setIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX));
this.setSelectedIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX_CHECKED));
this.setDisabledIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX_DISABLED));
this.setDisabledSelectedIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX_DISABLED_CHECKED));
this.setPressedIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX_PRESSED));
this.setRolloverIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX_ROLLOVER));
this.setRolloverSelectedIcon(new ImageIcon(Constantes.IMG_CAMINHO_CHECKBOX_ROLLOVER_SELECTED));
}
}
As you can see the path of the images are in the constants, creating JCheckBox
objects as demonstrated in the previously specified link.
Anyway, when I instantiate a ImageIcon
object unfortunately nothing happens. Neither error, and it does not appear in the panel. If I do it directly using ACheckBox
it works there.
What am I doing wrong? The image path question is correct because they are paths used in other objects that work (like JCheckBox
for example).
What can it be?