The variables field1
and area1
are only defined within the scope of the SecondLab
constructor. Declare these as class instance variables
private JTextField field1;
private JTextArea area1;
to make them visible from the actionPerformed
method. Also make sure to remove the initial keywords in the assignments
field1 = new JTextField();
area1 = new JTextArea();