Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Cant access JButtons outside of MouseListener
I Have array of JButtons if a 8x8 grid I want to click a button and change the icon of another in the grid (not the one clicked), I dont seem to be able to access the array outside the mouse listener.
//cant access this why?
private JButton but = new JButton;
private class MyMouseAdapter extends MouseAdapter
public void mouseClicked(MouseEvent event)
JButton button = (JButton)event.getSource(); // this gets the clicked button but
Any help would be great
0 · ·