its just too weird. there is a JPanel above a few buttons. On actionPerformed on one of them, i load an image to the JPanel. everything ok so far. The file is found, the image is rendered. immediately after, a big purple rectangle(???) is drawn over my image. The same color as the panel background, is like the piece of the image got deleted. I think is something with the repaint, but ignoring it or not, the problem persists. Even weirder, it seems to happen less often (usually only in the first time the button is clicked) if i use an image the same size of the panel (without scaling/stretching). The calls to load and display the image are the usual:
/*concats the file path, results in something like "../Media/image.png"*/
String selected = new String("../Media/" +h.getPictureName()+ ".png");
URL imageURL = getClass().getResource(selected);
BufferedImage bim = null;
try {
bim = ImageIO.read(imageURL);
}
catch (IOException ex) {
ex.printStackTrace();
}
Graphics2D g2 = (Graphics2D)imagePanel.getGraphics();
g2.drawImage(bim, 0, 0, imagePanel.getWidth(), imagePanel.getHeight(), null);
Any ideas are welcome, as are good exorcists contacts.
btw, im using java6, with netbeans 5.5