I am creating a calculator using Java Swing. When I implement the actionListener to any button in a class called buttonclick, it gives me an error "illegal start of expression". What should I do?
public class Frame extends JFrame
{
public Frame ()
{
JButton zero = new JButton ("0");
written = new JTextArea ();
private class buttonclick implements ActionListener
{
@Override
public void actionPerformed(ActionEvent e)
{
Object x = e.getSource();
if (x == zero)
written.setText(written.getText().concat("0"));
}
}
}
}
}
you are defining a private
local class in Frame()
constructor, private
modifier can't be used in methods
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments