I am getting an error that says "cannot refer to a non-final variable inside an inner class defined in a different method"
This is happening when I am trying to set up my timer referencing an action listener that I have constructed! This constructor simply displays a label and the timers desired effect is to run the action listener for 10 seconds but I can't get past this error. The code below shows he action listener and where he issue is occurring. I have put stars around the problematic areas. Thanks
**ActionListener actListner = new ActionListener() {
public void actionPerformed(ActionEvent event) {
lblgreenImage.setBounds(150,410,50,40);
repaint();
}
};**
btnEnter.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
String username = txtUserName.getText();
String accessCode = txtPin.getText();
String dataSourceName = "securitysystem";
String dbUrl = "jdbc:odbc:" + dataSourceName;
try{
//Type of connection driver used
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection variable or object param: dbPath, userName, password
Connection con = DriverManager.getConnection(dbUrl, "", "");
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("select username, pin from securitysystem.employee where username = '" + username + "' and pin = '" + accessCode + "'");
boolean nomatches=true;
while(rs.next())
{
String checkrs = rs.getString("username");
String checkPin = rs.getString("Pin");
if (username.equals(checkrs)) {
if (accessCode.equals(checkPin)) {
**Timer timer = new Timer(500, actListner);**
**timer.start();**