Problem in Disabling JButton in Java
<p>Good day!</p>

<p>I want to disable a button once I click it. My code is as follows..</p>

<pre><code>for (char buttonChar = 'a'; buttonChar &lt;= 'z'; buttonChar++) {
        String buttonText = String.valueOf(buttonChar);
        JButton letterButton = new JButton(buttonText);
        letterButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String actionCommand = e.getActionCommand();
                System.out.println("actionCommand is: " + actionCommand);
                letterButton.setEnabled(false);    //I disable the button here
            }
});
</code></pre>

<p>But an error appears: <code>local variable letter Button is accessed from the inner class; needs to be declared final</code>.. What does it mean? how can i resolve the issue?
Thank you...</p>
