-
Java (
http://www.daniweb.com/forums/forum9.html)
| tsfaridi | Oct 26th, 2009 1:29 am | |
| Problem in working with images in swing I am using this code for displaying images on JPanel, in which i succeeded, but the images are volatile. When i maximize or minimize the frame, it vanishes. |
public class ImagePanel extends JPanel{
private BufferedImage image;
public ImagePanel() {
try {
image = ImageIO.read(new File("image name and path"));
} catch (IOException ex) {
// handle exception...
}
}
@Override
public void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, this);
}
}
| BestJewSinceJC | Oct 26th, 2009 2:13 am | |
| This belongs in a normal thread, not in a code snippet. And I've experienced the same problem in the past, but I did a lot more debugging than you did. For example, when the window is resized, is your paintComponent method called? |
| tsfaridi | Oct 26th, 2009 4:11 am | |
| Thanks! you have shown me a path, i will work on it. Here the issue arises is, i am working on Checkers game, calling the paint method again will not resolve my issue. As the position of pieces will not be the same as initial.
@BestJewSinceJC: Kindly share with me your experience, how did you resolved this problem ?? |
| All times are GMT -4. The time now is 11:56 pm. | |
Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC