so i have a very basic java application, there is a panel and inside that is a button. When a user clicks the button, i want a picture to come up in another panel in the same form.
I searched up ways to load images from web/from my folder and this is the code i've come up with:-
private void buttonActionPerformed(java.awt.event.ActionEvent evt)
{
ImageIcon icon = new ImageIcon("URL-of-the-image");
panel2.setIcon(icon);
}
where am i going wrong? it says that the method "setIcon()" is causing a problem but i don't know any other method to do this job. Please Guide!
JPanel, it doesn't have asetIconmethod, you may want to use aJLabelinstead .