Change a button's icon from a different frame
Forgotten my old username and password! :| I also tried to search on the forums for this and it's of little help.
Anyhow, I am making a paint program for my project at uni. I have a panel (in a frame) that has buttons on them. Each button loads up a frame.
I made each frame has their own set of buttons so...
Tools button will open ToolsFrame which contains Pencil button, Paintbrush, Circle, etc.
What I want to do is change the Tools button icon so that it reflects whatever the user chose in the ToolsFrame. Is there a simple way of doing this?
I set the buttons up like...
JButton toolsBtn = new JButton("images/tools.JPG");
Pressing toolsBtn will make a new ToolsFrame object:
public void actionPerformed(ActionEvent e)
tools = new ToolsFrame();
ToolsFrame is a whole class extending JFrame and implementing ActionListener. The buttons in ToolsFrame are setup just like the toolsBtn above:
JButton paintbrushBtn = new JButton("images/paintbrush.JPG");
Pressing any button in ToolsFrame will close the window.