I have got a ImageIcon
in a Jlabel
in a JFrame
(Java GUI).
The ImageIcon
should get updated based on pressing a Calculate button (i.e. calcButton.addActionListener(new ActionListener()
) with part of the code in the method:
icon2 = new ImageIcon("M:\\Repos\\rtrans\\radTransPlot.png");
Plot1.setIcon(icon2);
frame.add(Plot1,gc);
frame.setVisible(true);
The initial ImageIcon
(icon1) is blank:
public class RadTransGui
{
private ImageIcon icon1 = new ImageIcon("M:\\Repos\\rtrans\\radTransPlotEmpty.png");
private ImageIcon icon2;
private JLabel Plot1 = new JLabel(icon1);
and gets properly updated based on the first Calculate button press but not after subsequent presses of Calculate button. The contents of M:\Repos\rtrans\radTransPlot.png gets updated correctly each time Calculate is pressed.
I have tried setting the ImageIcon to null and adding and removing the JLabel to the frame each time the Calculate button is pressed.
Any ideas? Thanks.