| | |
Problem in working with images in swing
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
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); } }
0
•
•
•
•
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?
0
•
•
•
•
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 ??
@BestJewSinceJC: Kindly share with me your experience, how did you resolved this problem ??
Similar Threads
- onclick problem in IE, working in FF/other (JavaScript / DHTML / AJAX)
- Problem loading images in ajax (JavaScript / DHTML / AJAX)
- Cross-Browser setTimeout Problem (JavaScript / DHTML / AJAX)
- Problem with uploading images to website (PHP)
- working laptop and working screen but no image.. (Monitors, Displays and Video Cards)
- CSS Working in FF, not in IE problem :) (HTML and CSS)
- Problem with GeForce 7800 GT OC (Monitors, Displays and Video Cards)
- search engine problem (Java)
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android animated api apple applet application arguments array arrays automation binary blackberry block bluetooth chat class classes client code component database detection developmenthelp draw eclipse encode error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer iphone j2me j2seprojects java javac javaprojects jmf jni jpanel julia lego linux list loop loops mac map method methods mobile netbeans newbie number object online oracle os page print problem program programming project recursion scanner screen server set singleton size sms socket sort sql string swing template test textfields threads time title transfer tree tutorial-sample update windows working



