private void pushButtonActionPerformed(java.awt.event.ActionEvent evt)
{
final int c=0;
final JDialog d=new JDialog();
JLabel l=new JLabel(\"Enter the E
but the line "c=Integer.parseInt(f.getText());" i am getting an error "cannot assign a value to a final variable
Right. The whole point of final variables is that you can only assign to them once, but you're trying to assign to it twice (once in the initialization setting it to 0, once in your quoted line). From the specification:
A variable can be declared
final. Afinalvariable may only be assigned to once. Declaring a variablefinalcan serve as useful documentation that its value will not change and can help avoid programming errors.It is a compile-time error if a
finalvariable is assigned to unless it is definitely unassigned (§16) immediately prior to the assignment.A blank
finalis afinalvariable whose declaration lacks an initializer.Once a
finalvariable has been assigned, it always contains the same value. If afinalvariable holds a reference to an object, then the state of the object may be changed by operations on the object, but the variable will always refer to the same object.
(Their emphasis, not mine.)
Instead of trying to track the state you're storing in c in a variable in the method, track it in a data member in the instance of your anonymous ActionListener you're creating.