How do you change the image in a JPanel?
Hey! (firstly, i need to use image on a JPanel, label&icon not an option).
I've made my JPanel class
publicclass DrawingPanelextends JPanel{
Image img;
DrawingPanel(){
Image img = Toolkit.getDefaultToolkit().getImage("13.jpg");//default image at startup
}
publicvoid paintComponent (Graphics g){
super.paintComponent (g);
// Use the image width & height to find the starting point
int imgX = getSize ().width/2 - img.getWidth (this);
int imgY = getSize ().height/2 - img.getHeight (this);
//Draw image centered in the middle of the panel
g.drawImage (img, 0, 0,this);
}// paintComponent
}// DrawingPanel
And I've made my instance of it and added it to the Frame:
DrawingPanel imagePanel =new DrawingPanel();
Now, I need to change the image on the JPanel according to the user's input. I have the string of the location of the new image. How do I update the JPanel to display this new image? Any help greatly appreciated!!

